From: Roedy Green on 15 Sep 2009 16:16 On Tue, 15 Sep 2009 17:57:29 +0100, "Frank Cisco" <tdyjkdftyujdtjyj(a)dtyjdtyjdtyjdty.com> wrote, quoted or indirectly quoted someone who said : >cheers all! why on earth is float used at all then if it's so inaccurate? If you are building a desk, whether it is 70.00000 cm deep or 70.00001 cm makes no difference. see http://mindprod.com/jgloss/floatingpoint.html -- 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)
From: Patricia Shanahan on 15 Sep 2009 16:20 Daniel Pitts wrote: > 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. You think they would be even better than double at spending resources to store and move meaningless bits? I suppose it is possible. Double has a relatively low upper bound on the number of meaningless bits. :-) Patricia
From: Arne Vajhøj on 15 Sep 2009 19:24 Frank Cisco wrote: > cheers all! why on earth is float used at all then if it's so inaccurate? Mostly historic reasons. Back when some MB's of RAM costed 100000's dollars, then the difference of having an array of float and having an array of double could be a lot of money. Today there is usually no reason at all. Arne
From: Arne Vajhøj on 15 Sep 2009 19:53 Roedy Green wrote: > 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. 24*log10(2) is a bit more than 6. Arne
From: Kevin McMurtrie on 16 Sep 2009 00:41
In article <6IPrm.105328$tD4.30915(a)newsfe07.ams2>, "Frank Cisco" <tdyjkdftyujdtjyj(a)dtyjdtyjdtyjdty.com> wrote: > cheers all! why on earth is float used at all then if it's so inaccurate? Sometimes you don't need a lot of accuracy but you do need speed and the ability to handle an extremely wide range of values. In data processing, you might sum any quantity of Input(n) * LUT(n) products than divide by the sum of LUT(0..n) to normalize. A fixed-point int is prone to having bits drop off one end or the other. A float holds its precision for any range. The 22 bits coming out are plenty for graphics, audio, data trending, performance metrics, etc. "float result = new Integer(i).floatValue()+f;" That's just dumb. Did you even look at what the floatValue() method does? Download src.jar and start reading. -- I will not see your reply if you use Google. |