mIRC Home    About    Download    Register    News    Help

Print Thread
problem with $calc identifier #239291 10/10/12 12:19 AM
Joined: Oct 2012
Posts: 1
D
darkman2012 Offline OP
Mostly harmless
OP Offline
Mostly harmless
D
Joined: Oct 2012
Posts: 1
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

Re: problem with $calc identifier [Re: darkman2012] #239292 10/10/12 02:11 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Re: problem with $calc identifier [Re: Riamus2] #239293 10/10/12 03:33 AM
Joined: Dec 2002
Posts: 344
D
drum Offline
Pan-dimensional mouse
Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 344
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.

Re: problem with $calc identifier [Re: drum] #239294 10/10/12 10:15 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net