Construct a JSON value that is a number.
Construct a JSON value that is a number.
Note: NaN, +Infinity and -Infinity are not valid json.
Construct a JSON value that is a number.
Construct a JSON value that is a number. Transforming NaN, +Infinity and -Infinity to jNull. This matches the behaviour of most browsers, but is a lossy operation as you can no longer distinguish between NaN and Infinity.
Construct a JSON value that is a number.
Construct a JSON value that is a number. Transforming NaN, +Infinity and -Infinity to their string implementations.
This is an argonaut specific transformation that allows all
doubles to be encoded without losing information, but aware
interoperability is unlikely without custom handling of
these values. See also jNumber
and jNumberOrNull
.
Returns true
iff this number wraps a Double
and it is
PositiveInfinity
or NegativeInfinitey
.
Returns true
iff this number wraps a Double
and it is
PositiveInfinity
or NegativeInfinitey
.
Returns true
iff this number wraps a Double
and it is NaN
.
Returns true
iff this number wraps a Double
and it is NaN
.
Returns true if this is a valid real number (ie.
Returns true if this is a valid real number (ie. !(isNaN || isInfinity)
).
Returns this number as a BigDecimal
.
Returns this number as a BigDecimal
.
Returns this number as a BigInt
, only if this number is an integer.
Returns this number as a BigInt
, only if this number is an integer.
Returns this number as a Byte
, only if this number is a valid Byte
.
Returns this number as a Byte
, only if this number is a valid Byte
.
Converts this number to the best Double
approximation to this number.
Converts this number to the best Double
approximation to this number.
Anything over Double.MaxValue
gets rounded to Double.PositiveInfinity
and anything below Double.MinValue
gets rounded to
Double.NegativeInfinitey
.
Converts this number to the best Float
approximation to this number.
Converts this number to the best Float
approximation to this number.
Anything over Float.MaxValue
gets rounded to Float.PositiveInfinity
and anything below Float.MinValue
gets rounded to
Float.NegativeInfinitey
.
Returns this number as a Int
, only if this number is a valid Int
.
Returns this number as a Int
, only if this number is a valid Int
.
Returns this number as a Long
, only if this number is a valid Long
.
Returns this number as a Long
, only if this number is a valid Long
.
Returns this number as a Short
, only if this number is a valid Short
.
Returns this number as a Short
, only if this number is a valid Short
.
Truncates the number to a BigInt.
Truncates the number to a BigInt. Truncation means that we round the real number towards 0 to the closest BigInt.
Truncates the number to a Byte.
Truncates the number to a Byte. Truncation means that we round the real
number towards 0 to the closest, valid Byte. So, if the number is 1e99,
then this will return Byte.MaxValue
.
Truncates the number to a Int.
Truncates the number to a Int. Truncation means that we round the real
number towards 0 to the closest, valid Int. So, if the number is 1e99,
then this will return Int.MaxValue
.
Truncates the number to a Long.
Truncates the number to a Long. Truncation means that we round the real
number towards 0 to the closest, valid Long. So, if the number is 1e99,
then this will return Long.MaxValue
.
Truncates the number to a Short.
Truncates the number to a Short. Truncation means that we round the real
number towards 0 to the closest, valid Short. So, if the number is 1e99,
then this will return Short.MaxValue
.