On Jan 30, 2012, at 9:32 AM, Tony Arcieri wrote:

> On Mon, Jan 30, 2012 at 12:22 AM, Robert Klemme
> <shortcutter / googlemail.com>wrote:
>=20
>> It seems many people use the "floating point mess" without major
>> issues.  So it cannot be as bad as you make it sound.
>>=20
>=20
> Floating points are a great choice for approximating continuous values =
and
> thus working on things which require both high performance and
> approximating real-world data sources. This includes things like =
games,
> non-gaming related 3D applications, perceptual media including audio =
and
> video codecs, and everything involved in working with perceptual media =
on
> computers such as non-linear editing, speech synthesis, and speech
> recognition.

Let me add "statistics gathering" to the list...

> People don't often do these things in Ruby. I'd say they're uncommon =
use
> cases.

... and suddenly, you have a _very_ common use case. I have no client
where it doesn't happen.

Graphing is also not uncommon.

>=20
> Something people do quite often in Ruby: deal with money. Money isn't
> continuous, it's discrete. A decimal type is a much better choice for
> dealing with money than a floating point.

Yes, but a dedicated money type that encodes the currency is also a much =
better
choice. Also the standard in handling monetary values is not using a =
decimal
representation anyways: you just encode the smallest value as an =
Integer.

> As I said before, I think Ruby could benefit from decimal literals. =
They
> can't solve all use cases. They can't be a replacement for rationals, =
such
> as in the 1D/3D example (actually I'm not entirely convinced of that
> either, but that's a sidebar)
> I have found many uses for BigDecimal before and have seen Fixnums =
used
> where BigDecimal would probably be more appropriate (i.e. "count =
cents, not
> dollars!") where having (Big)Decimal literals would probably change
> people's minds about that sort of thing.

Counting cents is perfectly valid, fits every database (even your fancy =
NOSQL
database that doesn't have a decimal type) and is the proper way to do =
math=20
involving money. The base value is not the Dollar, it is the
cent. This doesn't hold true if you venture into the realms of =
fractional
cents, but thats really uncommon (an can be solved by using Rational).

If money is the reason against float, its the wrong reason. It may be a =
tempting
error, but it only shows that the developer in question did not read a =
single=20
line about handling money in software - which is another common problem, =
but
not one that you can actually fix by the choice of literals.