Hi!
There is Peek() and ReadFloat() which all requires double precision floating point numbers which takes 64 bit in memory.
Is there a way to handle simple precision 32 bit fp numbers in Hollywood?
Bye!
floating point numbers
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: floating point numbers
No, in Hollywood all floating point values are 64-bit wide.
Re: floating point numbers
May I ask it for a new feature?
I'd like to use dr2d drawings directly and that format uses such numbers. There is an old dr2d to hpgl converter on Aminet which I wrote (dr_hpgl), and like to port to hollywood. A little tweak on hpgl and we get complex 2d drawings in the form that Polygon() needs.
I'd like to use dr2d drawings directly and that format uses such numbers. There is an old dr2d to hpgl converter on Aminet which I wrote (dr_hpgl), and like to port to hollywood. A little tweak on hpgl and we get complex 2d drawings in the form that Polygon() needs.
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: floating point numbers
Hmm, I don't really see the advantage 32-bit floats would bring over 64-bit floats... please enlighten me
Re: floating point numbers
The only advantage could be the ability to read files that stores single precision numbers.
But forget it, implemented as a function:
But forget it, implemented as a function:
Code: Select all
;##########################################
;# #
;# CONVERTS FLOATING POINT NUMBERS #
;# #
;# doubleprecision=sp2dp(singleprecision) #
;# #
;##########################################
Function sp2dp(sfp)
Local sign, exponent, significand
sign=(sfp>>31)&1
exponent=((sfp>>23)&255)-127
significand=sfp&$7fffff
Local sigdec=1
Local decoded=1
For Local i=23 To 0 Step -1
If BitTest(significand,i) Then decoded=decoded+sigdec
sigdec=sigdec/2
Next
decoded=decoded*2^exponent
If sign=1 Then decoded=decoded*-1
Return(decoded)
EndFunction