markcw, I got good and bad news about single precision. The good news is I found some good web document about the internals. The article has a C code example which does something that I need. I converted it to Blitz code. The bad news is, I have an imprecision in the fractions, yet again!!!! And it sounds like the same problems that we have generally speaking. The example code follows, and notice my debug prints ;) HINT: The first frac should of been 16384
Article: http://www.ragestorm.net/blogs/?p=57
pf (-772.1) WaitKey() End Function pf(x#) Print "float = " + x Local fb% = CreateBank(4) PokeFloat(fb,0,x) xx% = PeekInt(fb,0) sign% = xx Shr 31 expo% = ((xx Shr 23) And $ff) - $7F man% = (xx And ((1 Shl 23) - 1)) And $7FFFFFFF ; I removed the sign bit here (maybe pointless) man% = man Or (1 Shl 23) s$ = "" If sign = 1 Then s$ = "-" Print s$ + (man Shr (23 - expo)) + "." frac% = man And ((1 Shl (23 - expo)) -1) base% = 1 Shl (23 - expo) : Print "base:" + base c% = 0 While (frac > 0 And c < 6) c = c + 1 frac = frac * 10 : Print "frac:" + frac Print (frac / base) frac = frac Mod base Wend FreeBank(fb) End Function
Article: http://www.ragestorm.net/blogs/?p=57