mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2006
Posts: 167
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Aug 2006
Posts: 167
Is this a bug, or are the values simply out of range? (7.22)

//echo > $base(1000000000000000000000000000,10,36)
> 3HNDGL0B4IG4C4K8GS
//echo > $base(3HNDGL0B4IG4C4K8GS,36,10)
> 1000000000000000000000082442

//echo > $base(9400110200829385376875,10,36)
> 1J3TMP12TAE8KS4
//echo > $base(1J3TMP12TAE8KS4,36,10)
> 9400110200829382406864

Joined: Jul 2006
Posts: 4,130
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,130
It's not a bug, it's a limit from C if I'm not mistaken:

Code:
//echo -a $calc(123456789*123456789*123456789)


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2006
Posts: 167
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Aug 2006
Posts: 167
Is there any way to determine the largest supported value?

It would seem like a straightforward task, except in my demonstration, there are actually more corrupted digits in the smaller number than there are in the larger one. (Also, all of my experience in the real-life programming world has always been on the Turbo Pascal/Delphi side of the fence, so if the answer is something obvious for C programmers, it isn't for me.)

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Originally Posted By: pishposh
Is there any way to determine the largest supported value?


more precise would be the need to find the lowest non-supported value. this is related to an issue i'm dealing with trying to condense hex output from hashes like sha1 to fewer digits, but there was a limit to how many digits i could convert to base-36 without being able to convert from base-36 back to the original number, and it's not easy to tell whether mIRC was able to create the correct base-36 value and the error happened converting back to the original, or whether both values are wrong. i use the following alias to check numbers:

Code:
basetest {
  if ((!$2) || ($1 !isnum 1-36)) { echo -s syntax: /basetest BASE(1-36) value | halt }
  var %temp $2
  echo -s len $len($2) $2 from base $1 to 36 and back
  var %temp $base($2,$1,36)
  echo -s len $len(%temp) %temp as base 36
  echo -s final $base(%temp,36,$1) back to base $1
}


The smallest hex value i've found to return an error is:

//basetest 16 2 $+ $str(0,12) $+ 1

but the next higher number does not return an error, and there's a range of values where some return correct and some do not.

----

On a related note, i'm not sure if this is a bug or not, but $base isn't behaving as i expected when feeding invalid values to it. It seems to always allow all base-36 values from 0-9 and a-z, and the base only determines the multiplier to apply to each 'place' value.

//echo -a $base(a0,10,10) returns 100 instead of error/zero
//echo -a $base(z0,10,10) returns 350




Link Copied to Clipboard