mIRC Home    About    Download    Register    News    Help

Print Thread
hash table bug?? or max value? #186386 21/09/07 10:38 PM
Joined: Oct 2006
Posts: 48
G
Ghozer Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2006
Posts: 48
ok, a little background first, im using hash tables to store data from a text based, dcc chat game... part of the game im tracking a total.. and i found a bug, but im not 100% sure on the threshold...

is there a max value for a hash table entry?? if so, what is it? how can I avoid this? or is it indeed, a bug?

NOTE: it doesnt matter on the table, or item name, but I have put down here what im using...

Create a table, and an entry... set the value for the entry as 2099721840

/hmake stats 1000
/hadd stats tfactprod 2099721840

increse the item "tfactprod" by X (which is tallyd up in a while loop)

var %tot = $calc(%tot + %playertot)
(in this case, %tot = 74040191)

increse the hash table entry by %tot

/hinc stats tfactprod %tot
(have also used /hadd stats tfactprod $calc($hget(stats,tfactprod) + %tot) with the same outcome)

how echo back the table item...

/echo -a $hget(stats,tfactprod)

it will reply with -2121205265

WHY is it coming back with a minus figure??

2099721840 + 74040191 = 2173762031

even the figure, ignoring the minus is low..

any ideas?? wink -- can anyone find the threshold where it goes into minus figures etc?? .. basically, i need help :P

Re: hash table bug?? or max value? [Re: Ghozer] #186390 21/09/07 11:31 PM
Joined: Dec 2002
Posts: 503
B
Bekar Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
Welcome to 32bit signed integers. This appears to be a bug with 'hinc' wink

Reproduced here, v6.3 (XPSP2)

Re: hash table bug?? or max value? [Re: Ghozer] #186394 22/09/07 12:31 AM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Quote:
(have also used /hadd stats tfactprod $calc($hget(stats,tfactprod) + %tot) with the same outcome)

Hm, I can use hadd with $calc() and get the right result
Code:
//var %a = 2099721840,%b = 74040191 |  hadd -m test a %a | hadd test a $calc($hget(test,a) + %b) | echo -ag * $hget(test,a) == $calc(%a + %b) | hfree test

* 2173762031 == 2173762031

Re: hash table bug?? or max value? [Re: Bekar] #186774 26/09/07 10:33 AM
Joined: Oct 2003
Posts: 313
S
Sais Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Oct 2003
Posts: 313
Confirmed. You cannot hinc past 2147483647 (0x7FFFFFFF)

I assume $calc uses maths routines that allow for higher precision.

As you found, hadd table entry $calc(%val + %inc) will work correctly...at least up to the limits of $calc's precision! I guess this is because it's hadd'ing a string of digits, rather than performing calculation internally.

Last edited by Sais; 26/09/07 10:34 AM.

Sais
Re: hash table bug?? or max value? [Re: Sais] #186907 28/09/07 02:20 AM
Joined: Oct 2006
Posts: 48
G
Ghozer Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2006
Posts: 48
but using $calc() diddnt work for me, i still ended up with the same negative number in the hash table entry...

Re: hash table bug?? or max value? [Re: Ghozer] #186910 28/09/07 05:34 AM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Yet it works for me with the code I posted...

Re: hash table bug?? or max value? [Re: Ghozer] #186919 28/09/07 09:46 AM
Joined: Dec 2002
Posts: 4,728
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,728
Thanks this has been fixed for the next version.