class BigDecimal
The BigDecimal class provides operations for
arithmetic, scale manipulation, rounding, comparison and
format conversion. The #toString method provides a
canonical representation of a BigDecimal.
Constructor
Constructs an immutable arbitrary-precision signed decimal number.
A BigDecimal consists of an arbitrary precision integer
unscaled value and a 32-bit integer scale. If zero
or positive, the scale is the number of digits to the right of the
decimal point. If negative, the unscaled value of the number is
multiplied by ten to the power of the negation of the scale. The
value of the number represented by the BigDecimal is
therefore (unscaledValue × 10-scale).
Methods
add
(BigDecimal other)
Returns the sum of this and the given BigDecimal.
compare
(BigDecimal other)
Compares this BigDecimal with the given one.
equals
(BigDecimal other)
Returns true if the value of the BigDecimal instance and other are the same
BigDecimal.fromBuffer
(Buffer buf)
Returns the BigDecimal representation of a buffer composed of the scale (int32BE) and the unsigned value (varint BE)
- Static
- This function is static
BigDecimal.fromNumber
(Number value)
Returns a BigDecimal representation of the Number
- Static
- This function is static
BigDecimal.fromString
(String value)
Returns a BigDecimal representation of the string
- Static
- This function is static
greaterThan
(BigDecimal other)
Returns true if the current instance is greater than the other
isNegative
()isZero
()notEquals
(BigDecimal other)
subtract
(BigDecimal other)
Returns the difference of this and the given BigDecimal.
BigDecimal.toBuffer
(BigDecimal value)
Returns a buffer representation composed of the scale as a BE int 32 and the unsigned value as a BE varint
- Static
- This function is static
toJSON
()Returns the string representation. Method used by the native JSON.stringify() to serialize this instance.
toNumber
()Returns a Number representation of this BigDecimal.
toString
()Returns the string representation of this BigDecimal