ID:139285
 
mob/verb/Test()
world<<3600000000


What do you think this prints? I'll tell you... 2.14748e+009 (2147480000)

What the heck is going on? This is really messing up my code when the game somehow thinks 3.6 billion is actually 2.1 billion.

Can anyone tell me what is going on?

Test it out yourself, seriously...

[Edit] Ok I just did further testing and any number over 2.14748e+009 reads as 2.14748e+009.
BYOND has a limit on how high numbers can go. You'll have to find some other way of storing values if they go that high. (Splitting them into units for instance (100,000 silver = 10 gold))
<.< Weird, 2.14748e+009 (2147480000) seems to be the the highest number you can get no matter what.'


Edit: Ninja'd. Hmm, you're using this for your RP game, dragoon?
In response to Nadrew
Nadrew wrote:
BYOND has a limit on how high numbers can go. You'll have to find some other way of storing values if they go that high. (Splitting them into units for instance (100,000 silver = 10 gold))

This limit didn't used to exist, why does it now? I've used numbers WAY past 2.14 billion in the past. And I've seen games (including mine) use numbers in the trillions.

Also I just used admin on my game to edit one of my vars to 1 trillion and it is now 1 trillion so you must be wrong.
In response to Dragonn
It has existed for as long as I can remember, actually. I'm sure plenty of other games have found ways to get around this limitation in the past.
In response to Nadrew
Nadrew wrote:
It has existed for as long as I can remember, actually. I'm sure plenty of other games have found ways to get around this limitation in the past.

You have to be wrong because I just logged on to my game and edited a var to 1 trillion and it now has a value of 1 trillion. But it is not compiled in the latest version of BYOND. When using the latest version of BYOND on that same game, it caps at 2.14 billion.
In response to Dragonn
Are you perhaps using num2text? This has always been around, back since late 2003 when I joined.
In response to LordAndrew
LordAndrew wrote:
Are you perhaps using num2text? This has always been around, back since late 2003 when I joined.

The code I showed you is the exact code I used to test it. And if that is true how come I can use numbers in the trillions and beyond on the versions of my game currently being hosted?
In response to Dragonn
I did some tests, and it appears only compile-time values are being limited to ~2.1 billion. At runtime you can go much higher (most easily with input() as num) and hit #INF.

As mentioned, one work-around is to store numbers differently. Here's one option for that:
http://www.byond.com/developer/Hobnob/bignum
In response to DarkCampainger
Thanks.

This seems like a pretty big issue considering that it makes it extremely difficult to work with big numbers such as world.realtime when it can't even read them.

world.realtime is over 3.5 billion and it can't even read it in the code?

What if I need to run a check like: if(world.realtime<3600000000) (Which is sort of what I need to do, and it returns false, even though in reality it is true, because world.realtime's current value is 3.5 billion something)
In response to Dragonn
Dragonn wrote:
What if I need to run a check like: if(world.realtime<3600000000) (Which is sort of what I need to do, and it returns false, even though in reality it is true, because world.realtime's current value is 3.5 billion something)

I would suggest using time2text() to get just the portion of the date you actually care about (year?) and then use text2num() to convert that to a number you can compare to.
In response to Nadrew
Isn't it weird how BYOND is using floats to store numbers, but in this case it's limited to integer?
In response to Ripiz
Ripiz wrote:
Isn't it weird how BYOND is using floats to store numbers, but in this case it's limited to integer?

If I recall the spec correctly, a very large float wouldn't have any fractional components (because they would be insignificant and not stored in the mantissa)
In response to DarkCampainger
True, but float max value is up to e+039 if I remember correctly, while in this case it got stuck at 2.14748e+009, which is exactly integer limit (2^31-1).
In response to Ripiz
It's not a float, basically, as the compile-time number is whole. You can trapse the DMB in a hex editor and confirm this yourself.
In response to Ripiz
Numbers written as integers in the source are stored that way (as a 4-byte int) in the DMB file, and so are subject to the usual limits on integers (+/- 31 bits).

If the number had been written as 3600000000.0, it would have been stored as a floating-point number and not truncated (though of course would have the precision limitations inherent in fp numbers).

Compare:
mob/verb/test()
world<<3600000000
world<<3600000000.0


Note that in all calculations in DM are done with floating-point numbers, so anything stored initially as an int is automatically converted when you do anything with it.