Double
classin packageklyn
public class Double extends AbstractFloat implements ValueType
All Implemented Interfaces: ValueType

Represents a 64-bit IEEE 754 floating-point number.

Double is the default floating-point type used by Klyn for decimal literals without the f suffix. It supports arithmetic, comparison and explicit conversions from the primitive scalar types. The special words nan and inf also have type Double: nan represents a quiet not-a-number value, inf positive infinity and -inf negative infinity. Use nanf and inff when the required type is Float.

A NaN value is unordered: it is unequal to every value, including itself, and all <, <=, > and >= comparisons involving it return false.

Example
value = 3.5
other = Double("2.25")
notANumber = nan
positiveInfinity = inf
negativeInfinity = -inf

assert value + other == 5.75
assert type(notANumber) == Double
assert notANumber != notANumber
assert notANumber is nan
assert positiveInfinity is inf
assert negativeInfinity is -inf
assert positiveInfinity > value
assert negativeInfinity < value
Inherited Properties
propertyInherited Properties from Object: type
Constructors
Modifier and Type Member Description
public native Double Builds the neutral Double value (0.0).
public native Double
Double(value as Boolean)
Builds a Double from a Boolean value.
public native Double
Double(value as Char)
Builds a Double from a Unicode scalar value.
public native Double
Double(value as CodeUnit)
Builds a Double from a UTF-16 code-unit value.
public native Double
Double(value as Double)
Copy constructor.
public native Double
Double(value as Float)
Builds a Double from a Float value.
public native Double
Double(value as Int)
Builds a Double from an Int value.
public native Double
Double(value as Long)
Builds a Double from a Long value.
public native Double
Double(value as String) throws ValueException
Parses a Double from a textual representation.
public native Double
Double(value as UInt)
Builds a Double from a UInt value.
public native Double
Double(value as ULong)
Builds a Double from a ULong value.
Methods
Modifier and Type Member Description
public native override toString
toString() as String
Converts this value to its textual representation.
public static tryParse
tryParse( readonly value as String, out result as Double ) as Boolean
Parses text into a Double without propagating invalid-value errors.
Inherited Methods
methodInherited Methods from Object: deepCopy, fromJson, hash, toDict, toJson, toMap, toString, toXml
Operators
Modifier and Type Member Description
public native static operator<( readonly a as Double, readonly b as Double ) as Boolean Tests whether a is strictly lower than b.
public native static operator<=( readonly a as Double, readonly b as Double ) as Boolean Tests whether a is lower than or equal to b.
public native static operator!=( readonly a as Double, readonly b as Double ) as Boolean Tests whether two Double values are different.
public native static operator%( readonly a as Double, readonly b as Double ) as Double Computes the floor remainder, with the divisor's sign (including signed zero).
public native static operator%=( readonly a as Double, readonly b as Double ) as Void Replaces a with its floor remainder, with the divisor's sign.
public native static operator*( readonly a as Double, readonly b as Double ) as Double Multiplies two Double values.
public native static operator**( readonly value as Double, readonly power as Double ) as Double Raises a Double value to a Double power.
public native static operator**=( readonly value as Double, readonly power as Double ) as Void Replaces value with value ** power.
public native static operator*=( readonly a as Double, readonly b as Double ) as Void Multiplies a by b in place.
public native static operator+( readonly a as Double, readonly b as Double ) as Double Adds two Double values.
public native static operator+=( readonly a as Double, readonly b as Double ) as Void Adds b to a in place.
public native static operator-( readonly a as Double, readonly b as Double ) as Double Subtracts two Double values.
public native static operator-=( readonly a as Double, readonly b as Double ) as Void Subtracts b from a in place.
public native static operator/( readonly a as Double, readonly b as Double ) as Double Divides two Double values.
public native static operator/=( readonly a as Double, readonly b as Double ) as Void Divides a by b in place.
public native static operator==( readonly a as Double, readonly b as Double ) as Boolean Tests whether two Double values are equal.
public native static operator>( readonly a as Double, readonly b as Double ) as Boolean Tests whether a is strictly greater than b.
public native static operator>=( readonly a as Double, readonly b as Double ) as Boolean Tests whether a is greater than or equal to b.