From: Patricia Shanahan on
Frank Cisco wrote:
> cheers all! why on earth is float used at all then if it's so inaccurate?

There are situations in which it is very useful.

For example, some years ago I was doing some customer support work at a
geophysical consultancy. I saw they were doing some massive calculations
in float, and asked about it.

They had a numerical algorithms expert on staff who knew far more than
I'll ever know about numerical analysis and algorithm stability. Their
input data, seismic traces, was inherently imprecise. Similarly, they
only needed a few decimal digits in the output. The algorithms expert
had decided that, given the algorithms they were using, they would get
the digits they needed using float. Benchmarking showed a significant
performance difference, because using float halved the data volume.

If they had used double, they would have spent a lot of resources
storing and moving bits that were meaningless.

Patricia
From: Mike Schilling on
Patricia Shanahan wrote:
> Frank Cisco wrote:
>> cheers all! why on earth is float used at all then if it's so
>> inaccurate?
>
> There are situations in which it is very useful.
>
> For example, some years ago I was doing some customer support work at
> a geophysical consultancy. I saw they were doing some massive
> calculations in float, and asked about it.
>
> They had a numerical algorithms expert on staff who knew far more than
> I'll ever know about numerical analysis and algorithm stability. Their
> input data, seismic traces, was inherently imprecise. Similarly, they
> only needed a few decimal digits in the output. The algorithms expert
> had decided that, given the algorithms they were using, they would get
> the digits they needed using float. Benchmarking showed a significant
> performance difference, because using float halved the data volume.
>
> If they had used double, they would have spent a lot of resources
> storing and moving bits that were meaningless.

Note to self: double is ideal for analyzing marketing data.


From: markspace on
Frank Cisco wrote:
> cheers all! why on earth is float used at all then if it's so inaccurate?


The same reason people use ints instead of long: speed and memory
requirements.

Patricia's post explains this very well, I just thought I'd add the
int/long analogy too.

From: Daniel Pitts on
Mike Schilling wrote:
> Patricia Shanahan wrote:
>> Frank Cisco wrote:
>>> cheers all! why on earth is float used at all then if it's so
>>> inaccurate?
>> There are situations in which it is very useful.
>>
>> For example, some years ago I was doing some customer support work at
>> a geophysical consultancy. I saw they were doing some massive
>> calculations in float, and asked about it.
>>
>> They had a numerical algorithms expert on staff who knew far more than
>> I'll ever know about numerical analysis and algorithm stability. Their
>> input data, seismic traces, was inherently imprecise. Similarly, they
>> only needed a few decimal digits in the output. The algorithms expert
>> had decided that, given the algorithms they were using, they would get
>> the digits they needed using float. Benchmarking showed a significant
>> performance difference, because using float halved the data volume.
>>
>> If they had used double, they would have spent a lot of resources
>> storing and moving bits that were meaningless.
>
> Note to self: double is ideal for analyzing marketing data.
Bzzt... wrong.
"Ideal" would probably be a Rational ("a/b"), or BigDecimal.





--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
From: Roedy Green on
On Tue, 15 Sep 2009 17:17:40 +0100, "Frank Cisco"
<tdyjkdftyujdtjyj(a)dtyjdtyjdtyjdty.com> wrote, quoted or indirectly
quoted someone who said :

>
>Surely it should be 5454697.7388774? If I use double it's fine, but I need
>to use float

see http://mindprod.com/jgloss/floatingpoint.html

floats are only accurate to about 6 significant digits. You could try
double for better accuracy. If you want banker absolute precision, you
can't use floating point. You must use BigDecimal or BigInteger.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Many people tend to look at programming styles and languages like religions: if you belong to one, you cannot belong to others. But this analogy is another fallacy."
~ Niklaus Wirth (born: 1934-02-15 age: 75)