[REBOL] Re: Integer formatting
From: sags:apollo:lv at: 10-Feb-2006 19:27
This ir solution of mine, that I using together with round
function from library:
pad-decimal: func [ value [number!] len [integer!] /local s] [
s: form value
either len > 0 [
either all [ value = to-integer value ] [
head insert/dup tail s #"0" len - ((length? s) -
index? find s #".")
][
s: form either any [ greater? abs value 0.1 value = 0
] [
to-string value
][
replace insert to-string ( value / abs value ) +
value "0" "1." "0."
]
head insert/dup tail s #"0" len - ((length? s) -
index? find s #".")
]
][
copy/part s index? back find s "."
]
]
Janeks
On 10 Feb 2006 at 11:14, Steven White wrote: