Why don’t we have proper support for numbers in Ruby?
Numeric, Fixnum, Float, Bignum, Complex, Rational, BigDecimal…
What a mess! And they are often incompatible and can’t be safely
interchanged!
There MUST BE ONE SINGLE AND TRUE COMPLETE NUMERIC TYPE!!!
namely, class ArbitraryPrecisionHyperComplexNumber !
We’ll see
Why not do what R did — define “scalars” as vectors of length 1 and
make the vector the basic numeric type?
Then you have a conformability problem. How do you multiply a vector
times a scalar? If a scalar is represented by a vector of length one,
“doubling” a vector of length greater than one won’t work or will
require special code.
Why not do what R did — define “scalars” as vectors of length 1 and
make the vector the basic numeric type?
Then you have a conformability problem. How do you multiply a vector
times a scalar? If a scalar is represented by a vector of length one,
“doubling” a vector of length greater than one won’t work or will
require special code.
Ah, but R, like S, uses something called the recycling rule. Vector A of
length N times vector B of length M is defined by recycling the shorter
vector from the end back to the beginning. So [3 4 5] * [3] is [9 12
15], [2 3] + [7 8 9] is [9 11 11], etc.