Say you have a function that keeps returning #inf, and you want to check if this happens. Just say if it equals these constants!
global FLOAT_MAXVAL as float
global FLOAT_MINVAL as float
global FLOAT_PINF as float
global FLOAT_NINF as float
x as dword
make memblock 1,32
x=%01111111100000000000000000000000`= infinity
write memblock dword 1,0,x
FLOAT_PINF=memblock float(1,0)
x=%11111111100000000000000000000000`= +infinity
write memblock dword 1,0,x
FLOAT_NINF=memblock float(1,0)
x=%01111111011111111111111111111111`=maxval?
write memblock dword 1,0,x
FLOAT_MAXVAL=memblock float(1,0)
x=%11111111011111111111111111111111`=minval?
write memblock dword 1,0,x
FLOAT_MINVAL=memblock float(1,0)
print FLOAT_MAXVAL
print FLOAT_MINVAL
print FLOAT_PINF
print FLOAT_NINF
wait key
delete memblock 1
end
function FLOAT_NAN(n as float) `returns a 1 if n is not a number. If it's a number, or positive/neg infinity it returns 0.
write memblock float 1,0,n
x as dword
x=(memblock dword(1,0)<<1)>>24
if x=255 `float is #INF or #NAN
x=(memblock dword(1,0)<<9)>>9
if x=0 then exitfunction 0
exitfunction 1
endif
endfunction 0
Say you have a float, a, it is a number if:
a<>FLOAT_PINF, a<>FLOAT_NINF, and FLOAT_NAN(a)=0
this uses memblock number one, because it seems bitwise operators only work on integers and dwords?