Numeric Objects
In a sense this section is only required because of OO
languages that support the concept of a primitive
type (Java, C++) in languages like ruby and smalltalk and even python everything is an object. So you should prefer ruby x.abs
to vanilla processings abs(x)
etc.
Fixnum
Holds Integer values that can be represented in a native machine word (minus 1 bit). If any operation on a Fixnum exceeds this range, the value is automatically converted to a Bignum.
Float
Float objects represent inexact real numbers using the native architecture’s double-precision floating point representation. Floating point has a different arithmetic and is an inexact number.
constants
- DIG The minimum number of significant decimal digits in a double-precision floating point. Usually defaults to 15.
- EPSILON The difference between 1 and the smallest double-precision floating point number. Usually defaults to 2.2204460492503151e-16.
Bignum
Bignum objects hold integers outside the range of Fixnum. Bignum objects are created automatically when integer calculations would otherwise overflow a Fixnum. When a calculation involving Bignum objects returns a result that will fit in a Fixnum, the result is automatically converted.
Rational
A rational number can be represented as a paired integer number; a/b
(b>0). Where a
is numerator and b
is denominator. Integer a
equals rational a/1
mathematically. A rational object is an exact number, which helps you to write program without any rounding errors.
PiCrate
We have re-opened the Numeric
class to implement radians
and degree
methods, which means that instead of using radians(x)
a processing method, you should use x.radians
in PiCrate. But this should not be so necessary now we have DegLut.cos
and DegLut.sin
methods.