Page 1 of 1
floating point numbers
Posted: Sun Aug 14, 2011 9:22 am
by lazi
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!
Re: floating point numbers
Posted: Sun Aug 14, 2011 10:46 am
by airsoftsoftwair
No, in Hollywood all floating point values are 64-bit wide.
Re: floating point numbers
Posted: Sun Aug 14, 2011 10:00 pm
by lazi
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.
Re: floating point numbers
Posted: Mon Aug 15, 2011 10:20 pm
by airsoftsoftwair
Hmm, I don't really see the advantage 32-bit floats would bring over 64-bit floats... please enlighten me

Re: floating point numbers
Posted: Tue Aug 16, 2011 12:20 am
by lazi
The only advantage could be the ability to read files that stores single precision numbers.
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