Request: Double data types

Blitz3D Forums/Blitz3D Bug Reports/Request: Double data types

I couldn't find a DblToSng function anywhere. This might work but is untested.

Edit: Well it looks like it does work going by this simple test, although it's not incredibly accurate it is sufficient.
;DoubleToSingle Test

dblBank=CreateBank(8)

value#=359.1234
SngToDbl(value#,dblBank)
value_l=PeekInt(dblBank,0)
value_r=PeekInt(dblBank,4)

DblToSng(dblBank)
test#=PeekFloat(dblBank,0)

Print value#
Print test#
WaitKey()
End

Function SngToDbl( x#, bank )
 ;Thanks to Floyd for this one. His comments:
 ;This should convert all ordinary floats correctly.
 ;The extreme cases +Infinity, -Infinity, NaN
 ;would require special handling.

 Local s, e, m, Lo, Hi, n
 PokeFloat bank, 0, x#
 n = PeekInt( bank, 0 )  ; raw bits of x
 s = n And %10000000000000000000000000000000  ; sign bit
 e = n And %01111111100000000000000000000000  ; 8-bit exponent
 e = (e Shr 3) + %00111000000000000000000000000000  ; 11-bit exponent
 m = n And %00000000011111111111111111111111  ; 23-bit mantissa
 Lo = m Shl 29  ; final three bits of mantissa
 Hi = s Or e Or (m Shr 3 ) ; sign, exponent, first twenty bits of m
 PokeInt bank, 0, Lo
 PokeInt bank, 4, Hi

End Function

Function DblToSng( bank )
 ;DoubleToSingle
 ;http://techsupt.winbatch.com/TS/T000001034F21.html
 ;bank -> input as double floating point value
 ;Returns value in bank as single floating point value

 Local DL, DH, Dsign, Ssign, Dexp, Sexp, Sfract
 DL = PeekInt(bank,0)
 DH = PeekInt(bank,4)
 Dsign = Abs(DH Shr 31)
 Ssign = Dsign Shl 31
 Dexp = Abs(DH Shr 20 - (Dsign Shl 11))
 Sexp = Dexp + 127 - 1023
 Sexp = Sexp Shl 23
 Sfract = ((DH And 1048575) Shl 3) + (DL Shr 28)
 PokeInt bank,0,Ssign Or Sexp Or Sfract

End Function