proc
AddCommas(Num as num)
var/Tnum=num2text(round(Num),100000)
var/l=length(Tnum)
var/mod=1
world<<"[Tnum]=[l]"
for(var/i=3,l>i,i+=3)
var/first="[copytext(Tnum,1,length("[Tnum]")-(i-mod))]"
var/second="[copytext(Tnum,length("[Tnum]")-(i-mod))]"
Tnum="[first],[second]"
mod--
return Tnum
mob/verb/Add_Comma(n as num)
world<<"[AddCommas(n)]"
The output when starting at 1 and adding a 0 to the end everytime goes like this:
1=1
1
10=2
10
100=3
100
1000=4
1,000
10000=5
10,000
100000=6
100,000
1000000=7
1,000,000
10000000=8
10,000,000
100000000=9
100,000,000
1000000000=10
1,000,000,000
10000000000=11
10,000,000,000
99999997952=11 *Notice the input here was 100000000000.
99,999,997,952
Can anyone see what's wrong with this?
Solution: Don't use numbers that high.
Lummox JR