[Gambas-user] Hex string to float

hjherbert at ...20... hjherbert at ...20...
Sat Dec 13 17:06:09 CET 2008


Float number as you mean are 32 bit float numbers see http://en.wikipedia.org/wiki/Single_precision
Float numbers in GAMBAS are 64 bit float numbers see http://en.wikipedia.org/wiki/Double_precision

The follow program demonstrates how to convert a 64 Bit long value into a 64 bit gambas FLOAT (=double precision) value:

PUBLIC SUB Main()
DIM f AS Float
DIM l AS Long
DIM hH AS File


l = &h3fd5555555555555&

OPEN "/tmp/hexfloat.tmp" FOR WRITE CREATE AS #hH
WRITE #hH, l
CLOSE #hH
OPEN "/tmp/hexfloat.tmp" FOR READ AS #hH
READ #hH, f
CLOSE #hH
PRINT "l=", l, "HEX", Hex$(l), "  f=", f

END






More information about the User mailing list