Skip to content

Update nf to show right-hand formatting examples #775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion content/api_en/nf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ String se = nf(e, 5, 3);
println(se); // Prints "00040.200"
String sf = nf(f, 3, 5);
println(sf); // Prints "009.01200"

String sf2 = nf(f, 0, 5);
println(sf2); // Prints "9.01200"
String sf3 = nf(f, 0, 2);
println(sf3); // Prints "9.01"
]]></code>
</example>

<description><![CDATA[
Utility function for formatting numbers into strings. There are two versions: one for formatting floats, and one for formatting ints. The values for the <b>digits</b>, <b>left</b>, and <b>right</b> parameters should always be positive integers.<br /><br />As shown in the above example, <b>nf()</b> is used to add zeros to the left and/or right of a number. This is typically for aligning a list of numbers. To <em>remove</em> digits from a floating-point number, use the <b>int()</b>, <b>ceil()</b>, <b>floor()</b>, or <b>round()</b> functions.
Utility function for formatting numbers into strings. There are two versions: one for formatting floats, and one for formatting ints. The values for the <b>digits</b> and <b>right</b> parameters should always be positive integers. The <b>left</b> parameter should be positive or 0. If it is zero, only the right side is formatted.<br /><br />As shown in the above example, <b>nf()</b> is used to add zeros to the left and/or right of a number. This is typically for aligning a list of numbers. To <em>remove</em> digits from a floating-point number, use the <b>int()</b>, <b>ceil()</b>, <b>floor()</b>, or <b>round()</b> functions.
]]></description>

</root>