Abstraction of numeric types with a natural
total order, including the built-in numeric
types Integer
and Float
.
A Number
has a well-defined magnitude
together with a
sign
of type Integer
, defined for any instance x
as follows:
x==0
then x.sign==0
and x.magnitude==0
,x>0
then x.sign==1
and x.magnitude==x
, orx<0
then x.sign==-1
and x.magnitude==-x
,where 0
is the additive identity of the numeric type.
Not every value commonly considered to be a “number” is
a Number
. For example, complex numbers aren't Number
s
since they don't have a total order.
no type hierarchy
Attributes | |
absolute | See magnitude |
fractionalPart | shared formal Other fractionalPart The fractional part of this number, after truncation of
the integral part. For |
magnitude | shared default Other magnitude The magnitude of this number, defined for any instance
where
Aliases: absolute |
negative | shared formal Boolean negative Determine if the number is strictly negative, that is,
if |
positive | shared formal Boolean positive Determine if the number is strictly positive, that is,
if |
sign | shared default Integer sign |
wholePart | shared formal Other wholePart The integral value of the number after truncation of
the fractional part. For |
Inherited Attributes |
Attributes inherited from: Object |
Attributes inherited from: Invertible<Other> |
Methods | |
plusInteger | shared formal Other plusInteger(Integer integer) The result of adding this number to the given
|
powerOfInteger | shared formal Other powerOfInteger(Integer integer) The result of raising this number to the given
non-negative Throws
|
timesInteger | shared formal Other timesInteger(Integer integer) The result of multiplying this number by the given
|
Inherited Methods |
Methods inherited from: Object |
Methods inherited from: Comparable<Other> |
Methods inherited from: Invertible<Other> |
Methods inherited from: Numeric<Other> |
Methods inherited from: Summable<Other> |