Fixed-point arithmetic library

J

Jan Burse

Robert said:
And that is not exactly how FP arithmetic is described in Wikipedia:

"For simplicity, fixed-point multiply procedures use the same result
format as the operands. This has the effect of keeping the middle bits;
the I-number of least significant integer bits, and the Q-number of most
significant fractional bits. Fractional bits lost below this value
represent a precision loss which is common in fractional multiplication.
If any integer bits are lost, however, the value will be radically
inaccurate."

It boils down to how fixed "fixed" is. In my understanding decimal
places are fixed throughout the whole calculation which is not what BD
does (obviously to avoid precision loss).

Kind regards

robert

In this respect fixnums and limited precission floating point
numbers are not that different. Take a single precission
floating point number from Java:

float a, b;

The above has 23-bit mantissa, which amounts to ~8 decimal
digits. If you multiply two numbers you don't get ~16
decimal digits, it is also rounded to ~8 decimals.

The difference between fixnums and floating point numbers
is only, that fixnums have no exponent. The exponent
floating points extends the range but not the precision.

For fixnums you have to be a little bit more careful
with the range. Adapt your choice of fixnums to the
expected range of your application.

BigDecimals are not fixnums per-se. They are also
floating point, but precision can be arbirary high. So
they are not limited precision floating points.

Bye
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top