nf() \ Language (API) \ Processing 1.0
Search processing.org:
Language (A-Z) \
Libraries \
Tools \
Environment \
Compare \
Troubleshooting
Reference for Processing version 1.0+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.
Name
nf()
Examples
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"
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 digits, left, and right parameters should always be positive integers.As shown in the above example, nf() is used to add zeros to the left and/or right of a number. This is typically for aligning a list of numbers. To remove digits from a floating-point number, use the int(), ceil(), floor(), or round() functions.
Syntax
nf(intValue, digits)
nf(floatValue, left, right)
Parameters
intValue
int or int[]: the number(s) to format
digits
int: number of digits to pad with zeroes
floatValue
float or float[]: the number(s) to format
left
int: number of digits to the left of the decimal point
right
int: number of digits to the right of the decimal point
Returns
String or String[]
Usage
Web & Application
Related
nfs()nfp()nfc()
Updated on February 28, 2009 08:32:28pm PST
Processing was initiated by Ben Fry and Casey Reas. It is developed by a small team of volunteers.
© Info \
Site hosted by Media Temple!
Wyszukiwarka
Podobne podstrony:
NF 2005 09 operacja transylwaniaNF 2005 02 siła wizjiNF 2005 06 wielki powrót von keiseraNF 2005 10 prawo seriiNF 2005 05 balet słoniNF 2005 08 pocałunek śmierciNF 2005 10 misja animal planetNF 2005 12NF 2005 06 dębyNF 2005 10 śniąc w lesie wyniosłych kotówNF 2005 08 twórcaNF 2005 02 tatuażNF 2005 02 podróżnicyMTB 45D1 NF BSNF 2005 10 ujrzeć gwiazdyNF 2005 11 puls maszynyNF 2005 12 bezludzieNF 2005 02 interesy nie idą dobrzeNF 2005 08 tajemnicaNF 2005 12 łzy sobekawięcej podobnych podstron