Request: Double data types

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

This should explain it.
;Passing Doubles to a DLL in Blitz Example
;Thanks to Michael Reitzenstein

;gluPerspective has 4 doubles for parameters:
;gluPerspective(fovy as Double,aspect as Double,zNear as Double,zFar as Double)

;Blitz does not have an 8-byte data type that you can pass by value
;but this syntax can be used instead:
;blitz_gluPerspective(fovy_hi%,fovy_low%,aspect_hi%,aspect_low%,zNear_hi%,zNear_low%,zFar_hi%,zFar_low%):"gluPerspective"

;The decls file should look like this:
;;Glu32.decls
;.lib "Glu32.dll"
;blitz_gluPerspective(fovy_l%,fovy_r%,aspect_l%,aspect_r%,zNear_l%,zNear_r%,zFar_l%,zFar_r%):"gluPerspective"

;Then a blitz wrapper function is made:
;Function gluPerspective(fovy#,aspect#,zNear#,zFar#)
;The only difference is that you call it with Blitz floats
;instead of doubles.

Function gluPerspective(fovy#,aspect#,zNear#,zFar#)

 Local dblBank,fovy_l,fovy_r,aspect_l,aspect_r
 Local zNear_l,zNear_r,zFar_l,zFar_r

 dblBank=CreateBank(8)

 SngToDbl fovy#,dblBank
 fovy_l=PeekInt(dblBank,0)
 fovy_r=PeekInt(dblBank,4)
 
 SngToDbl aspect#,dblBank
 aspect_l=PeekInt(dblBank,0)
 aspect_r=PeekInt(dblBank,4)

 SngToDbl zNear#,dblBank
 zNear_l=PeekInt(dblBank,0)
 zNear_r=PeekInt(dblBank,4)

 SngToDbl zFar#,dblBank
 zFar_l=PeekInt(dblBank,0)
 zFar_r=PeekInt(dblBank,4)

 FreeBank dblBank

 blitz_gluPerspective fovy_l,fovy_r,aspect_l,aspect_r,zNear_l,zNear_r,zFar_l,zFar_r

End Function

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