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 | Source Codeshared formal Other fractionalPart The fractional part of this number, after truncation of
the integral part. For |
magnitude | Source Codeshared default Other magnitude The magnitude of this number, defined for any instance
where
Aliases: absolute |
negative | Source Codeshared formal Boolean negative Determine if the number is strictly negative, that is,
if |
positive | Source Codeshared formal Boolean positive Determine if the number is strictly positive, that is,
if |
sign | Source Codeshared default Integer sign |
wholePart | Source Codeshared 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 | |
compare | Source Codeshared actual default Comparison compare(Other other) Compares this number with the given number, returning: Refines Comparable.compare |
plusInteger | Source Codeshared formal Other plusInteger(Integer integer) The result of adding this number to the given
Since 1.1.0 |
powerOfInteger | Source Codeshared formal Other powerOfInteger(Integer integer) The result of raising this number to the given
non-negative Throws
Since 1.1.0 |
timesInteger | Source Codeshared formal Other timesInteger(Integer integer) The result of multiplying this number by the given
Since 1.1.0 |
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> |