Name

nfp()

Examples
a = 200
b = -40
c = 90
sa = nfp(a, 10)
print(sa)  # Prints "+0000000200"
sb = nfp(b, 5)
print(sb)  # Prints "-00040"
sc = nfp(c, 3)
print(sc)  # Prints "+090"

d = -200.94
e = 40.2
f = -9.012
sd = nfp(d, 10, 4)
print(sd)  # Prints "-0000000200.9400"
se = nfp(e, 5, 3)
print(se)  # Prints "+00040.200"
sf = nfp(f, 3, 5)
print(sf)  # Prints "-009.01200"
Description Utility function for formatting numbers into strings. Similar to nf() 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 digits, left, and right parameters should always be positive integers.
Syntax
nfp(num, digits)
nfp(num, left, right)
Parameters
numthe number(s) to format
digitsint: number of digits to pad with zeroes
leftint: the number of digits to the left of the decimal point
rightint: the number of digits to the right of the decimal point
Related nf()
nfs()
nfc()
Updated on Tue Jul 11 06:52:24 2017.
Creative Commons License