Files
processing4/mobile/web/reference/API/nfp.xml
2005-01-27 06:48:42 +00:00

83 lines
1.9 KiB
XML

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<name>nfp()</name>
<category>Data</category>
<subcategory>String Functions</subcategory>
<usage>Web &amp; Application</usage>
<example>
<image></image>
<code>
int a=200, b=-40, c=90;
String sa = nfp(a, 10);
println(sa); // prints "+0000000200"
String sb = nfp(b, 5);
println(sb); // prints "-00040"
String sc = nfp(c, 3);
println(sc); // prints "+090"
float d = -200.94, e = 40.2, f = -9.012;
String sd = nfp(d, 10, 4);
println(sd); // prints "-0000000200.9400"
String se = nfp(e, 5, 3);
println(se); // prints "+00040.200"
String sf = nfp(f, 3, 5);
println(sf); // prints "-009.01200"
</code>
</example>
<description>
Utility function for formatting numbers into strings. Similar to <b>nf()</b> but puts a "+" in front of positive numbers and a "-" in front of negative numbers. 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>
nfp(intValue, digits)
nfp(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()
nf()
</related>
<availability>1.0</availability>
<type>Function</type>
<partof>Core</partof>
<level>Extended</level>
</root>