' Max limits of representation for float/single, double, extended
' comparing with TCC/float.h and
' //http://www.naic.edu/~phil/hardware/vertex/sharemegsvertex/lcu/pcr/c600/include/FLOAT.H
$ filename "RangeLimits.exe"
'uses rtl32
'uses rtl64
uses console
SetConsoleTitle("Max Representation of Float, Double, Extended")
string fmt(int v){ return right(hex(v,8),8) }
float f, double d, extended e
int *i, quad *q
'FLT_MAX 3.402823466e+38F /* max value */
f=2^127*1.9999999
@i=@f
printl "Max float = " f tab "hex: " hex(i,8)
f=-f
printl "Max -float = " f tab "hex: " right(hex(i),8)
'FLT_MIN 1.175494351e-38F /* min positive value */
f=2^-126
printl "Min positive = " f tab "hex: " hex(i,8)
printl
'DBL_MAX 1.7976931348623158e+308 /* max value */
d=2^1023*1.9999999999999998
@q=@d
printl "Max double = " d tab "hex: " hex(q)
d=-d
printl "Max -double = " d tab "hex: " hex(q)
'DBL_MIN 2.2250738585072014e-308 /* min positive value */
d=2^-1022
printl "Min positive = " d tab "hex: " hex(q,16)
printl
'LDBL_MAX 1.189731495357231765e+4932L /* max value */ 'a bit different
e=2^16384
@i=@e
printl "Max extended = " e tab "hex: " fmt(i[3]and 0xffff) " " fmt(i[2]) " " fmt(i[1])
e=-e
printl "Max -extended = " e tab "hex: " fmt(i[3]and 0xffff) " " fmt(i[2]) " " fmt(i[1])
'LDBL_MIN 3.3621031431120935063e-4932L /* min positive value */ 'quite different
e=2^-16330
printl "Min positive = " e tab "hex: " fmt(i[3]and 0xffff) " " fmt(i[2]) " " fmt(i[1])
printl
printl "Enter ..." : waitkey