ID:148936
 
mob/var/hp = 0 as num

mob/Stat()
..()
statpanel("sdafd")
stat("HP:","[num2text(src.hp,99999999)]")
mob/verb/AddHP(N as num)
hp += N

mob/verb/Thingy()
src << src.hp


But the thing is I add this to the hp(99999999), and this is what I see in the statpanel.. 100000000

Why when I add 0 to 99999999 I get 100000000. Would that make the BYOND system inaccurate with adding? Please give me the 411
Super16 wrote:
mob/var/hp = 0 as num

mob/Stat()
..()
statpanel("sdafd")
stat("HP:","[num2text(src.hp,99999999)]")
mob/verb/AddHP(N as num)
hp += N

mob/verb/Thingy()
src << src.hp


But the thing is I add this to the hp(99999999), and this is what I see in the statpanel.. 100000000

Why when I add 0 to 99999999 I get 100000000. Would that make the BYOND system inaccurate with adding? Please give me the 411

Change

>   stat("HP:","[num2text(src.hp,99999999)]")

to
>   stat("HP:",src.hp)


In response to Malver (#1)
I don't want it to display scientific notation. That's what num2text does. Do this and tell me what you get

mob/verb/Thing()
var/result = 0
var/thing = 99999999
result += thing
src << result

You will get 100000000. That's a problem.
It's not about adding. I believe it's about storage. A computer has a finite amount of bits to store things in. At a certain point, small differences are pretty much ignored. (It's not exactly a BYOND thing.)

world << "[99999999]" will output 1e+008 whether or not you add anything. So will 99999998. Those numbers are huge.
In response to Super16 (#2)
Super16 wrote:
I don't want it to display scientific notation. That's what num2text does. Do this and tell me what you get

mob/verb/Thing()
var/result = 0
var/thing = 99999999
result += thing
src << result

You will get 100000000. That's a problem.

You can make your own proc for this; it will be limited to the accuracy of floating point, but it should suffice for this. With your own proc, you can also put in commas:
proc/num2text2(n,precision=6)
var/t=""
var/neg=(n<0)
if(neg) n=-n
var/digit
if(n-round(n))
t="."
var/dec=n-round(n)
while(dec && (precision--))
dec*=10;digit=round(dec);dec-=digit
t+="[digit]"
while(dec)
digit=dec%1000
dec-=digit
if(!dec) t="[digit][t]"
else
t=",[copytext("[digit+1000]",2)][t]"
dec=round(dec/1000,1) // account for rounding error
if(neg) t="-[t]"
return t

Lummox JR
In response to Lummox JR (#4)
Lummox JR wrote:
Super16 wrote:
I don't want it to display scientific notation. That's what num2text does. Do this and tell me what you get

mob/verb/Thing()
var/result = 0
var/thing = 99999999
result += thing
src << result

You will get 100000000. That's a problem.

You can make your own proc for this; it will be limited to the accuracy of floating point, but it should suffice for this. With your own proc, you can also put in commas:
proc/num2text2(n,precision=6)
> var/t=""
> var/neg=(n<0)
> if(neg) n=-n
> var/digit
> if(n-round(n))
> t="."
> var/dec=n-round(n)
> while(dec && (precision--))
> dec*=10;digit=round(dec);dec-=digit
> t+="[digit]"
> while(dec)
> digit=dec%1000
> dec-=digit
> if(!dec) t="[digit][t]"
> else
> t=",[copytext("[digit+1000]",2)][t]"
> dec=round(dec/1000,1) // account for rounding error
> if(neg) t="-[t]"
> return t

Lummox JR

You do know you will get an error. For dec being an undefined var. You defined for only under the if statement.. Just wanted to tell you that...