More Awesome Than You!

TS2: Burnination => The Podium => Topic started by: rufio on 2010 January 25, 20:23:33



Title: Primitive 0x2, int32, and overflow
Post by: rufio on 2010 January 25, 20:23:33
I am guessing that the expression primitive does signed 16-bit math, correct?  Is there any way to coerce it into doing 32-bit math, or unsigned math, or getting it to check for overflow?  Or would I have to implement that myself if I wanted it?


Title: Re: Primitive 0x2, int32, and overflow
Post by: J. M. Pescado on 2010 January 26, 06:07:28
I am guessing that the expression primitive does signed 16-bit math, correct?  Is there any way to coerce it into doing 32-bit math, or unsigned math, or getting it to check for overflow?
Nope.


Title: Re: Primitive 0x2, int32, and overflow
Post by: Inge on 2010 January 26, 16:20:46
EA make liberal use of mod and div and store values in multiple variables, one for units, one for tens of thousands etc :) 


Title: Re: Primitive 0x2, int32, and overflow
Post by: J. M. Pescado on 2010 January 26, 18:12:17
That method is only used to store money and not really for anything else, and represents more of a special, handmade behavior than true 32-bit math.


Title: Re: Primitive 0x2, int32, and overflow
Post by: rufio on 2010 January 26, 18:42:06
Yes, I was actually looking at the earned money value when I asked this - if you use the Date Counter thingy from Darcyland to track wealth, you can see that there appears to be some kind of horrible overflow problem with it, so that my sim has apparently made "92 thousand, -3029 simoleans".  It obviously doesn't affect things badly enough that sims can't still make $100K in a reasonable amount of time, but it's extremely annoying when I'm trying to keep track as I go along.  I don't know why they didn't simply use (or simulate) 32-bit ints there - it would have made much more sense and probably would have been easier to debug.