Suraj Kurapati
10/7/2006 3:22:00 PM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Vincent Fourmond wrote:
> David Vallner wrote:
>> Suraj N. Kurapati wrote:
>>> Furthermore, what about automatic Float -> BigDecimal conversion?
>> Wouldn't that only be possible if the processor reports if an IEEE
>> floating-point conversion / operation was inprecise / innacurate (can't
>> for the heck of it remember which term applies here.)
>>
>> Even if that was the case, that means that say a floating point division
>> would take would take one attempt, report that, convert the floating
>> point numbers to BigDecimals, and then perform the division in Ruby.
>
> I think that basically every operation on a number which doesn't have
> a natural writing in base 2 would trigger the conversion. That is,
> unless you do 2 * 0.5, you'll switch automatically to BigDecimal. Bad
> idea. Why don't you use BigDecimal systematically, if you're really
> worried about precision ?
Well, manually applying BigDecimal wherever necessary for
performance reasons feels like programming in C (remember floats and
doubles? /me vomits).
When I was learning Ruby, I absolutely *loved* the fact that Fixnum
automatically spills into Bignum and vice versa... good riddance to
short, int, long, and long long! Just think of how beneficial this
conceptual abstraction (I don't care how many bits it occupies, I
just want to use this integer!) has been to your code and mode of
thinking. If Ruby didn't have this, we would be manually checking
sizes, upcasting, and downcasting Fixnums and Bignums everywhere. :-(
I don't care so much about performance; rather, I want to write code
quickly and elegantly using conceptual abstractions. If I really
need performance, I will profile the code and re-write the slow
parts in C.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
iD8DBQFFJ8ZvmV9O7RYnKMcRAi5NAJ47Kby2Bo6OaZU2LWBeEJ8iJ9Sh+wCcDzqz
eAlA7MMIlci1VyaBmojAcL8=
=A4po
-----END PGP SIGNATURE-----