Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: ejonesI don't know of a trick. It seems to require good old fashioned programming using the BrainScript while loop, the div() and mod() functions.
So if that value you want converted is in the variable n you could do this:
a = split(format("%f",n),".")
if a.len() > 1
then {
decimal = "." + str(a[1])
while decimal.right(1) == "0" decimal = left(decimal,strlen(decimal)-1)
} else {
decimal = ""
}
t = long(floor(n))
if t >= 1000
then s = format("%03ld",t.mod(1000))
else s = format("%3ld",t.mod(1000))
t = t.div(1000)
while (t > 0) {
if t >= 1000
then s = format("%03ld %s",t.mod(1000),s)
else s = format("%3ld %s",t.mod(1000),s)
t = t.div(1000)
}
emit trim(s + decimal) as Converted