mirror of
https://github.com/processing/processing4.git
synced 2026-02-12 10:00:42 +01:00
87 lines
1.7 KiB
XML
87 lines
1.7 KiB
XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
<root>
|
|
<name>nf()</name>
|
|
|
|
<category>Data</category>
|
|
|
|
<subcategory>String Functions</subcategory>
|
|
|
|
<usage>Web & Application</usage>
|
|
|
|
<example>
|
|
<image></image>
|
|
<code>
|
|
int a=200, b=40, c=90;
|
|
String sa = nf(a, 10);
|
|
println(sa); // prints "0000000200"
|
|
String sb = nf(b, 5);
|
|
println(sb); // prints "00040"
|
|
String sc = nf(c, 3);
|
|
println(sc); // prints "090"
|
|
|
|
float d = 200.94, e = 40.2, f = 9.012;
|
|
String sd = nf(d, 10, 4);
|
|
println(sd); // prints "0000000200.9400"
|
|
String se = nf(e, 5, 3);
|
|
println(se); // prints "00040.200"
|
|
String sf = nf(f, 3, 5);
|
|
println(sf); // prints "009.01200"
|
|
</code>
|
|
</example>
|
|
|
|
<description>
|
|
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.
|
|
</description>
|
|
|
|
<syntax>
|
|
nf(intValue, digits)
|
|
nf(floatValue, left, right)
|
|
</syntax>
|
|
|
|
<parameter>
|
|
<label>intValue</label>
|
|
<description>int: the number to format</description>
|
|
</parameter>
|
|
|
|
<parameter>
|
|
<label>digits</label>
|
|
<description>int: number of digits to pad with zeroes</description>
|
|
</parameter>
|
|
|
|
<parameter>
|
|
<label>floatValue</label>
|
|
<description>float: the number to format</description>
|
|
</parameter>
|
|
|
|
<parameter>
|
|
<label>left</label>
|
|
<description>int: number of digits to the left of the decimal point</description>
|
|
</parameter>
|
|
|
|
<parameter>
|
|
<label>right</label>
|
|
<description>int: number of digits to the right of the decimal point</description>
|
|
</parameter>
|
|
|
|
<returns>String</returns>
|
|
|
|
<related>
|
|
nfs()
|
|
nfp()
|
|
</related>
|
|
|
|
<availability>1.0</availability>
|
|
|
|
<type>Function</type>
|
|
|
|
<partof>Core</partof>
|
|
|
|
|
|
<level>Extended</level>
|
|
|
|
|
|
|
|
|
|
|
|
</root>
|