Calculation not working?
#2

Do you mean when the "time" parameter you pass in is greater than 10 digits? If this algorithm works fine for numbers under 10 digits then I would guess it's because of how the underlying bits are represented for Pawn variables. A 32-bit signed integer has a range of -2,147,483,648 to 2,147,483,647 (~10 digits). Any single variable in SA:MP's Pawn is a 32-bit signed integer.

When a variable goes over the 32-bit signed integer maximum it will wrap around to the lowest negative integer that can be represented in 32-bits. It is not something you can fix in your script, only something you can work around. Possible workarounds include using a "BigInteger" array instead of a single variable (it's not part of SA:MP, you'll have to build it yourself or hope someone else has), limit the accuracy of your timespan (e.g. have 1 unit mean an hour instead of minutes or seconds), or simply don't allow numbers past the maximum to be passed to the method.

See the documentation for cellmax in the Pawn Language Guide (pawn-lang.pdf) for proof of usual the largest number in Pawn. You can also see cellbits to know how many bits are in a cell.
Reply


Messages In This Thread
Calculation not working? - by Rokzlive - 05.08.2013, 00:49
Re: Calculation not working? - by Simon - 05.08.2013, 01:33
Re: Calculation not working? - by Rokzlive - 05.08.2013, 01:41
Re: Calculation not working? - by Simon - 05.08.2013, 01:44
Re: Calculation not working? - by Rokzlive - 05.08.2013, 01:45

Forum Jump:


Users browsing this thread: 1 Guest(s)