Skip to content

float zeropaddedstring

Chris Petersen edited this page Oct 16, 2014 · 1 revision

float->zeropaddedstring converts a float to string. This version always shows precision number of digits beyond the decimal point.

Parameter Description
x Floating point number
p Precision

Example

Example 1: Convert the number 100.513 to a string with 2 digits of precision

> (float->zeropaddedstring 100.513 2)
"100.51"

Example 2: Convert the number 7.3 to a string with 2 digits of precision

> (float->zeropaddedstring 7.3 2)
"7.30"

Example 3: Convert the number 3 to a string with 2 digits of precision

> (float->zeropaddedstring 3 2)
"3.00"
Clone this wiki locally