Re: Problem in Float Arithmetic
- From: "Doug Harrison [MVP]" <dsh@xxxxxxxx>
- Date: Sat, 05 Jul 2008 16:22:31 -0500
On Sat, 05 Jul 2008 14:34:30 -0400, Joseph M. Newcomer
<newcomer@xxxxxxxxxxxx> wrote:
When integers and integers only are represented as doubles, and the operations are limited
to add, subtract, and multiply, then the precision of a double is the same as the
precision of an integer of the same number of bits of significance as the mantissa of the
floating point number. The problem, for example, is that 'float' has fewer bits than
'int', so it only becomes interesting when you start using 'double'.
Right, I couldn't imagine using anything but double for this. However, if
int was 16 bits, the usual 32 bit float could work (23 bit mantissa), but
it would almost certainly be better to use long, which has at least 32
bits. The only exception I can think of is some weird hardware that has a
fast FPU but a really lousy ALU that can't do 32 bit integers.
Once "divide" comes into play, life gets very dicey even if the only values are initially
integral.
joe
What I said to David was:
<q>
Floating point arithmetic on integer values that produces integer values is
exact over a wide range, something like +/- 2^53 for double.
</q>
I did not mean anything but exactly what I wrote. Are you saying it's not
true for division? (If not, too bad for languages like Perl, I guess.)
--
Doug Harrison
Visual C++ MVP
.
- Follow-Ups:
- Re: Problem in Float Arithmetic
- From: Joseph M . Newcomer
- Re: Problem in Float Arithmetic
- References:
- Re: Problem in Float Arithmetic
- From: David Webber
- Re: Problem in Float Arithmetic
- From: Doug Harrison [MVP]
- Re: Problem in Float Arithmetic
- From: David Webber
- Re: Problem in Float Arithmetic
- From: Doug Harrison [MVP]
- Re: Problem in Float Arithmetic
- From: David Webber
- Re: Problem in Float Arithmetic
- From: Doug Harrison [MVP]
- Re: Problem in Float Arithmetic
- From: Joseph M . Newcomer
- Re: Problem in Float Arithmetic
- Prev by Date: Re: Addendum to serial port question RE: different parity types
- Next by Date: Re: Highlighting a line/arc
- Previous by thread: Re: Problem in Float Arithmetic
- Next by thread: Re: Problem in Float Arithmetic
- Index(es):
Relevant Pages
|