baseConvert() & 32-bit ops (was Best array population & access optimization)

Dar Scott dsc at swcp.com
Sat Jun 21 12:06:00 EDT 2003


On Saturday, June 21, 2003, at 10:23 AM, Dar Scott wrote:

> I thought I'd report the negative number problem with baseConvert.

I'm on OS X; I haven't checked this on other platforms.

OK, Mark, here is what I've learned.  The baseConvert() does not return 
the 2's complement if the msb of the 32-bit intermediate value is 1 as 
I had thought.  It tacks a minus sign onto the result if it is 1.  This 
will give you bad data for sure.  One workaround is if your result of 
baseConvert(hexStr,16,10) starts with a minus, remove it.  Since you 
want this numerical internally anyway, you can simple abs() the result. 
  Either will continue to work if/when the bug is fixed.

This might explain the negative numbers.

(The baseConvert() function also addresses a minus sign in the input 
numeral.  I think this might have trouble, too, but this should not 
concern you.)

Wanna see my test script and results?

I'll report this.

Dar Scott






More information about the use-livecode mailing list