case class JsonDecimal extends JsonNumber with Product with Serializable
A JsonDecimal represents and valid JSON number as a String. Unfortunately,
there is no type in the Scala standard library which can represent all valid
JSON decimal numbers, since the exponent may be larger than an Int. Such
a number can still be round tripped (parser to printer). We lazily parse the
string to a BigDecimal or a Double on demand.
- Alphabetic
- By Inheritance
- JsonDecimal
- Serializable
- Serializable
- Product
- Equals
- JsonNumber
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
asJson: Json
- Definition Classes
- JsonNumber
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(that: Any): Boolean
- Definition Classes
- JsonNumber → AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- JsonNumber → AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
normalized: (BigInt, BigDecimal)
Returns a *normalized* version of this Decimal number.
Returns a *normalized* version of this Decimal number. Since BigDecimal cannot represent all valid JSON value exactly, due to the exponent being limited to an
Int, this method let's us get a normalized number that can be used to compare for equality.The 1st value (BigInt) is the exponent used to scale the 2nd value (BigDecimal) back to the original value represented by this number. The 2nd BigDecimal will always either be 0 or a number with exactly 1 decimal digit to the right of the decimal point. If the 2nd value is 0, then the exponent will always be 0 as well.
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
lazy val
toBigDecimal: BigDecimal
Returns this number as a
BigDecimal.Returns this number as a
BigDecimal.- Definition Classes
- JsonDecimal → JsonNumber
-
def
toBigInt: Option[BigInt]
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.- Definition Classes
- JsonNumber
-
def
toByte: Option[Byte]
Returns this number as a
Byte, only if this number is a validByte.Returns this number as a
Byte, only if this number is a validByte.- Definition Classes
- JsonNumber
-
lazy val
toDouble: Option[Double]
Returns this number as a
Double, only if this number can be represented as aDouble.Returns this number as a
Double, only if this number can be represented as aDouble.- Definition Classes
- JsonNumber
-
lazy val
toFloat: Option[Float]
Returns this number as a
Float, only if this number can be represented as aFloat.Returns this number as a
Float, only if this number can be represented as aFloat.- Definition Classes
- JsonNumber
-
def
toInt: Option[Int]
Returns this number as a
Int, only if this number is a validInt.Returns this number as a
Int, only if this number is a validInt.- Definition Classes
- JsonNumber
-
def
toLong: Option[Long]
Returns this number as a
Long, only if this number is a validLong.Returns this number as a
Long, only if this number is a validLong.- Definition Classes
- JsonDecimal → JsonNumber
-
def
toShort: Option[Short]
Returns this number as a
Short, only if this number is a validShort.Returns this number as a
Short, only if this number is a validShort.- Definition Classes
- JsonNumber
-
def
truncateToBigInt: BigInt
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.
- Definition Classes
- JsonNumber
-
def
truncateToByte: Byte
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.- Definition Classes
- JsonNumber
-
def
truncateToDouble: Double
Truncates this number to the best
Doubleapproximation to this number.Truncates this number to the best
Doubleapproximation to this number. Anything overDouble.MaxValuegets rounded toDouble.PositiveInfinityand anything belowDouble.MinValuegets rounded toDouble.NegativeInfinity.- Definition Classes
- JsonNumber
-
def
truncateToFloat: Float
Truncates this number to the best
Floatapproximation to this number.Truncates this number to the best
Floatapproximation to this number. Anything overFloat.MaxValuegets rounded toFloat.PositiveInfinityand anything belowFloat.MinValuegets rounded toFloat.NegativeInfinity.- Definition Classes
- JsonNumber
-
def
truncateToInt: Int
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.- Definition Classes
- JsonNumber
-
def
truncateToLong: Long
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.- Definition Classes
- JsonNumber
-
def
truncateToShort: Short
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.- Definition Classes
- JsonNumber
- val value: String
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )