Fixed-point math Number to Interger
UltraLazer
Posts: 30
What the fastest way to convert a fixed point number ("Fixed-point math with trig functions in SPIN" from obex) to an Integer?
Right now I am converting the number to a string with .QvalToStr then from string to integer with a hacked piece of code. this takes far too long.
sub Question (may answer question one): How a the fixed point number encoded in 32bits?
Thanks
Right now I am converting the number to a string with .QvalToStr then from string to integer with a hacked piece of code. this takes far too long.
sub Question (may answer question one): How a the fixed point number encoded in 32bits?
Thanks
Comments
In case of the integer part, simply shift the number 16 times to right.
In case of rounding add 0.5 to the number (= 2^15) to it and take the integer part.
The MS 16 bit are for the signed integer part, the LS 16 bits are for the fraction.
Cheers,
Istvan