Friday, September 13, 2013

#fast IEEE 754 double to int32 @ music-dsp

at the music-dsp mailing list there was a short discussion about a "double -> int" rounding hack present in the JUCE library. i've posted an alternative solution that does the same without IEE 754 arithmetic. i'm sure similar solutions can be found in libraries and for CPU's that don't have a floating point co-processor unit. code is for c99.

http://music.columbia.edu/pipermail/music-dsp/2013-September/071572.html

can be summarized into:
1) separate double into mantissa, exponent, sign bit
2) depending on exponent value shift the mantissa left or right by the difference of the exponent and the amount of bits in the mantissa
3) truncate and receive a 32bit integer, while applying the original double's sign

--

0 comments: