[rust-dev] Appeal for CORRECT, capable, future-proof math, pre-1.0
ml at isaac.cedarswampstudios.org
Fri Jan 10 21:58:59 PST 2014
Scheme's numeric tower is one of the best in extant languages. Take a
look at it. Of course, its dynamic typing is poorly suited for Rust.
Arbitrary-precision arithmetic can get you mathematically perfect
integers and rational numbers, but not real numbers. There are an
uncountably infinite number of real numbers and sophisticated computer
algebra systems are devoted the problem (or estimates are used, or you
become unable to compare two real numbers for equality). The MPFR C
library implements arbitrarily high precision floating point, but that
still has all the pitfalls of floating-point that you complain about.
For starters, try representing sqrt(2) and testing its equality with
e^(0.5 ln 2).
In general, Rust is a systems language, so fixed-size integral types are
important to have. They are better-behaved than in C and C++ in that
signed types are modulo, not undefined behaviour, on overflow. It could
be nice to have integral types that are task-failure on overflow as an
option too. As you note, bignum integers are important too; it's good
they're available. I think bignum rationals would be a fine additional
choice to have (Haskell and GMP offer them, for example).
On 01/11/2014 12:15 AM, Lee Braiden wrote:
> This may be go nowhere, especially so late in Rust's development, but I
> feel like this is an important, relatively small change (though a
> high-profile one). I believe it could have a large, positive impact in
> terms of targeting new developer communities, gaining more libraries and
> applications, giving a better impression of the language, AND on
> performance and futureproofing.
> However, a lot of people who are interested in performance will probably
> baulk at this, on first sight. If you're in that group, let me
> encourage you to keep reading, at least until the points on performance
> /improvements/. Then baulk, if you like ;)
> Also, I said it in the post as well, but it's late here, so apologies
> for any readability / editing issues. I tried, but sleep beckons ;)
> Rust-dev mailing list
> Rust-dev at mozilla.org
More information about the Rust-dev