mIRC Homepage
Posted By: darkman2012 problem with $calc identifier - 10/10/12 12:19 AM
hello guys i just have problem with $calc identifier
for what reason this don't work?

Code:
//echo -a substract $calc(900000186448273800000000 - 1)
//echo -a add $calc(900000186448273800000000 + 1)


the $calc identifier don't substract 1 to the 900000186448273800000000 amount or amounts bigges. I have a money system on my bot and when i try to add small amounts to large amounts or small amounts subtract large numbers.


So my question is: this is a bug? i try to do that operation using /inc & /dec commands and not working too. someboy have a fix for that..?

Thanks in advance
Posted By: Riamus2 Re: problem with $calc identifier - 10/10/12 02:11 AM
mIRC is 32bit and the $calc function is based on that. That means you can only use numbers up to 32bit in size. Anything larger won't work correctly.
Posted By: drum Re: problem with $calc identifier - 10/10/12 03:33 AM
Originally Posted By: Riamus2
mIRC is 32bit and the $calc function is based on that. That means you can only use numbers up to 32bit in size. Anything larger won't work correctly.


It appears that mIRC stores numbers as 64-bit (double) floating point numbers.

If that's a correct guess, then integer values will only work reliably up to approximately 15 decimal digits (which is significantly more than a 32-bit integer).

So basically, darkman2012, stick to numbers that are 15 digits or less and you will be fine.
Posted By: Riamus2 Re: problem with $calc identifier - 10/10/12 10:15 AM
Thanks for the correction. I didn't try to see how large of a number was possible. Either way, it's a limitation and not a bug.

Note that you can get around the limitation by being creative in how you manage large numbers. Things like splitting numbers into 2 smaller parts and then concatenating them once you're done doing your calculations.
© mIRC Discussion Forums