An IEEE 754 64-bit floating point number. A Float
is
capable of approximately representing numeric values
between:
Zero is represented by distinct instances +0.0
, -0.0
,
but these instances are equal. -0.0
can be distinguished
from +0.0
using f == 0.0 && f.strictlyNegative
.
In addition, the following special values exist:
infinity
and -infinity
, andAs required by the IEEE standard no undefined value is
equal to any other value, nor even to itself. Thus, the
definition of equals()
for Float
violates the general
contract defined by Object.equals()
.
A floating point value with a zero fractionalPart
is
considered equal to its integer
part.
Literal floating point values are written with a decimal point and, optionally, a magnitude or exponent:
1.0 1.0E6 1.0M 1.0E-6 1.0u
In the case of a fractional magnitude, the decimal point is optional. Underscores may be used to group digits into groups of three.
no subtypes hierarchy
Constructors | |
Float | Source Codeshared Float(Float float) |
Attributes | |
absolute | See magnitude |
finite | Source Codeshared Boolean finite |
fractionalPart | Source Codeshared actual Float fractionalPart The fractional part of this number, after truncation of
the integral part. For Refines Number.fractionalPart |
hash | Source Codeshared actual Integer hash A platform-dependent hash code for this Refines Object.hash |
infinite | Source Codeshared Boolean infinite |
integer | Source Codeshared Integer integer This value, represented as an Throws
Since 1.1.0 |
magnitude | Source Codeshared actual Float magnitude The magnitude of this number, defined for any instance
where
Refines Number.magnitude Aliases: absolute |
negated | Source Codeshared actual Float negated The additive inverse of this value. Refines Invertible.negated |
negative | Source Codeshared actual Boolean negative Determines if this value is a negative number or
Refines Number.negative |
notANumber | See undefined |
positive | Source Codeshared actual Boolean positive Determines if this value is a positive number or
Refines Number.positive |
sign | Source Codeshared actual Integer sign The sign of this value. Produces Refines Number.sign |
strictlyNegative | Source Codeshared Boolean strictlyNegative Determines if this value is a negative number, |
strictlyPositive | Source Codeshared Boolean strictlyPositive Determines if this value is a positive number, |
string | Source Codeshared actual String string A string representing this floating point number.
See also formatFloat() Refines Object.string |
undefined | Source Codeshared Boolean undefined Determines whether this value is undefined. The IEEE standard denotes undefined values NaN (an abbreviation of Not a Number). Undefined values include:
An undefined value has the property that it is not
equal ( If
See also compare() Aliases: notANumber |
wholePart | Source Codeshared actual Float wholePart The integral value of the number after truncation of
the fractional part. For Refines Number.wholePart |
Inherited Attributes |
Attributes inherited from: Object |
Attributes inherited from: Invertible<Other> |
Attributes inherited from: Number<Other> |
Methods | |
compare | Source Codeshared actual Comparison compare(Float other) Compare this value to the given value, where
Note that if
|
divided | Source Codeshared actual Float divided(Float other) The quotient obtained by dividing this number by the
given number. For integral numeric types,
this operation rounds toward When the given divisor is exactly Refines Numeric.divided |
equals | Source Codeshared actual Boolean equals(Object that) Determines if the given object is equal to this
Or if:
Refines Object.equals |
format | Source Codeshared static String format(Float float, Integer minDecimalPlaces = 1, Integer maxDecimalPlaces = ..., Character decimalSeparator = ..., Character? thousandsSeparator = null) The string decimal representation of the given
floating point number. If the given number is
negative, the string representation
will begin with The number of decimal places following the decimal
point is controlled by the parameters
For example:
Finally:
This function never produces a representation involving scientific notation. Parameters:
See also parse() , Integer.format() Since 1.3.1 |
largerThan | Source Codeshared actual Boolean largerThan(Float other) Determines if this value is strictly larger than the
given value, where Refines Comparable.largerThan |
largest | Source Codeshared static Float largest(Float x, Float y) The larger of the two given floating point values, or
an Since 1.3.2 |
max | Source Codeshared static Float|Absent max<Absent>(Iterable<Float,Absent> floats) The largest floating point value in the given stream,
Since 1.3.2 |
min | Source Codeshared static Float|Absent min<Absent>(Iterable<Float,Absent> floats) The smallest floating point value in the given stream,
Since 1.3.2 |
minus | Source Codeshared actual Float minus(Float other) The difference between this number and the given
number. Must produce the value Refines Invertible.minus |
notLargerThan | Source Codeshared actual Boolean notLargerThan(Float other) Determines if this value is smaller than or equal to the
given value, where Refines Comparable.notLargerThan |
notSmallerThan | Source Codeshared actual Boolean notSmallerThan(Float other) Determines if this value is larger than or equal to the
given value, where Refines Comparable.notSmallerThan |
parse | Source Codeshared static Float|ParseException parse(String string) The If the given string representation contains more digits
than can be represented by a The syntax accepted by this method is the same as the
syntax for a Float: Sign? Digits ('.' Digits)? (Magnitude|Exponent) Sign: '+' | '-' Magnitude: 'k' | 'M' | 'G' | 'T' | 'P' | 'm' | 'u' | 'n' | 'p' | 'f' Exponent: ('e'|'E') Sign? Digits Digits: ('0'..'9')+ See also format() , Integer.parse() Since 1.3.1 |
plus | Source Codeshared actual Float plus(Float other) The result of adding the given value to this value. This operation should never perform any kind of mutation upon either the receiving value or the argument value. For any two instances x + y Refines Summable.plus |
plusInteger | Source Codeshared actual Float plusInteger(Integer integer) The result of adding this number to the given
Refines Number.plusInteger |
power | Source Codeshared actual Float power(Float other) The result of raising this number to the given floating
point power, where, following the definition of the
IEEE
Furthermore:
If this is a For any negative power
Refines Exponentiable.power |
powerOfInteger | Source Codeshared actual Float powerOfInteger(Integer integer) The result of raising this number to the given integer
power, where the following indeterminate forms evaluate
to
For any negative integer power
Refines Number.powerOfInteger |
product | Source Codeshared static Float product({Float*} floats) The product of all the floating point values in the
given stream, This expression produces the geometric mean of a list of floating point values: Float.product(list) ^ (1.0/list.size) Since 1.3.2 |
smallerThan | Source Codeshared actual Boolean smallerThan(Float other) Determines if this value is strictly smaller than the
given value, where Refines Comparable.smallerThan |
smallest | Source Codeshared static Float smallest(Float x, Float y) The smaller of the two given floating point values, or
an Since 1.3.2 |
sum | Source Codeshared static Float sum({Float*} floats) The sum of all the floating point values in the given
stream, This expression produces the mean of a list of floating point values: Float.sum(list) / list.size Since 1.3.2 |
times | Source Codeshared actual Float times(Float other) The product of this number and the given number. Refines Numeric.times |
timesInteger | Source Codeshared actual Float timesInteger(Integer integer) The result of multiplying this number by the given
Refines Number.timesInteger |
Inherited Methods |
Methods inherited from: Object |
Methods inherited from: Comparable<Other> |
Methods inherited from: Exponentiable<This,Other> |
Methods inherited from: Invertible<Other> |
Methods inherited from: Number<Other> |
Methods inherited from: Numeric<Other> |
Methods inherited from: Summable<Other> |