abstract class NumericModule extends AnyRef

The model of our floating point decimal numbers.

These are numbers of precision 38 (38 decimal digits), and variable scale (from 0 to 37 bounds included).

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. NumericModule
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new NumericModule()

Type Members

  1. abstract type Numeric <: BigDecimal

    Type Numeric represents fixed scale BigDecimals, aka Numerics.

    Type Numeric represents fixed scale BigDecimals, aka Numerics. Scale of Numerics can be between 0 and maxPrecision (bounds included). For any valid scale s we denote (Numeric s) the set of Numerics of scale s. Numerics are encoded using java BigDecimal, where the scale is the scale of the Numeric.

    We use java BigDecimals instead of scala ones because:

    • We prefer to use here lower level methods from java
    • We want two numerics with different scales to be different (w.r.t. ==)
  2. type Scale = ScaleModule.Scale
  3. sealed abstract class ScaleModule extends AnyRef

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. val Scale: ScaleModule
  5. final def add(x: Numeric, y: Numeric): Either[String, Numeric]

    Adds the two Numerics.

    Adds the two Numerics. The output has the same scale as the inputs. In case of overflow, returns an error message instead.

    Requires the scale of x and y are the same.

  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. final def assertFromBigDecimal(scale: Scale, x: BigDecimal): Numeric

    Like fromBigDecimal but throws an exception instead of returning e message in case of error.

    Like fromBigDecimal but throws an exception instead of returning e message in case of error.

    Annotations
    @throws(scala.this.throws.<init>$default$1[IllegalArgumentException])
  8. final def assertFromBigDecimal(scale: Scale, x: BigDecimal): Numeric

    Like fromBigDecimal but throws an exception instead of returning e message in case of error.

    Like fromBigDecimal but throws an exception instead of returning e message in case of error.

    Annotations
    @throws(scala.this.throws.<init>$default$1[IllegalArgumentException])
  9. def assertFromString(s: String): Numeric

    Like fromString, but throws an exception instead of returning a message in case of error.

    Like fromString, but throws an exception instead of returning a message in case of error.

    Annotations
    @throws(scala.this.throws.<init>$default$1[IllegalArgumentException])
  10. final def assertFromUnscaledBigDecimal(x: BigDecimal): Numeric

    Like fromUnscaledBigDecimal, but throws an exception instead of returning a message in case of error.

    Like fromUnscaledBigDecimal, but throws an exception instead of returning a message in case of error.

    Annotations
    @throws(scala.this.throws.<init>$default$1[IllegalArgumentException])
  11. def checkWithinBoundsAndRound(scale: Scale, x: BigDecimal): Either[String, Numeric]

    Like the previous function but with scala BigDecimals instead of java ones.

  12. def checkWithinBoundsAndRound(scale: Scale, x: BigDecimal): Either[String, Numeric]

    Checks that a BigDecimal falls between minValue(scale) and maxValue(scale), and round the number according to scale.

    Checks that a BigDecimal falls between minValue(scale) and maxValue(scale), and round the number according to scale. Note that it does _not_ fail if the number contains data beyond scale.

  13. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
  14. final def compareTo(x: Numeric, y: Numeric): Int

    Returns -1, 0, or 1 as x is numerically less than, equal to, or greater than y.

    Returns -1, 0, or 1 as x is numerically less than, equal to, or greater than y.

    Requires the scale of x and y are the same.

  15. final def divide(scale: Scale, x: Numeric, y: Numeric): Either[String, Numeric]

    Divides x by y.

    Divides x by y. The output has the scale scale. If rounding must be performed, the banker's rounding convention is applied. In case of overflow, returns an error message instead.

  16. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  18. final def fromBigDecimal(scale: Scale, x: BigDecimal): Either[String, Numeric]

    Like fromBigDecimal(Int, BigDecimal) but with a scala BigDecimal.

  19. final def fromBigDecimal(scale: Scale, x: BigDecimal): Either[String, Numeric]

    Converts the java BigDecimal x to a (Numeric scale). In case scale is not a valid Numeric scale or x cannot be represented as a (Numeric scale) without loss of precision, returns an error message instead.

  20. final def fromLong(scale: Scale, x: Long): Either[String, Numeric]

    Converts the Long x to a (Numeric scale). In case scale is not a valid Numeric scale or x cannot be represented as a (Numeric scale), returns an error message instead.

  21. def fromString(s: String): Either[String, Numeric]

    Given a string representation of a decimal returns the corresponding Numeric, where the number of digits to the right of the decimal point indicates the scale.

    Given a string representation of a decimal returns the corresponding Numeric, where the number of digits to the right of the decimal point indicates the scale. If the input does not match -?([1-9]\d*|0).(\d*) or if the result of the conversion cannot be mapped into a numeric without loss of precision returns an error message instead.

  22. final def fromUnscaledBigDecimal(x: BigDecimal): Either[String, Numeric]

    Like the previous function but with scala BigDecimal

  23. final def fromUnscaledBigDecimal(x: BigDecimal): Either[String, Numeric]

    Convert a BigDecimal to the Numeric with the smallest possible scale able to represent the former without loss of precision.

    Convert a BigDecimal to the Numeric with the smallest possible scale able to represent the former without loss of precision. Returns an error if such Numeric does not exists.

    Use this function to convert BigDecimal with unknown scale.

  24. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  25. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  26. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  27. val maxPrecision: Int

    Maximum usable precision for Numerics

  28. final def maxValue(scale: Scale): Numeric

    Returns the largest Numeric of scale scale

  29. final def minValue(scale: Scale): Numeric

    Returns the smallest Numeric of scale scale

  30. final def multiply(scale: Scale, x: Numeric, y: Numeric): Either[String, Numeric]

    Multiplies x by y.

    Multiplies x by y. The output has the scale scale. If rounding must be performed, the banker's rounding convention is applied. In case of overflow, returns an error message instead.

  31. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  32. final def negate(x: Numeric): Numeric

    Negate the input.

  33. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  34. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  35. final def round(targetScale: Long, x: Numeric): Either[String, Numeric]

    Rounds the x to the closest multiple of 10^targetScale using the banker's rounding convention. The output has the same scale as the input. In case of overflow, returns an error message instead.

  36. final def scale(numeric: Numeric): Scale
  37. final def subtract(x: Numeric, y: Numeric): Either[String, Numeric]

    Subtracts y to x.

    Subtracts y to x. The output has the same scale as the inputs. In case of overflow, returns an error message instead.

    Requires the scale of x and y are the same.

  38. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  39. final def toLong(x: Numeric): Either[String, Long]

    Returns the integral part of the given decimal, in other words, rounds towards 0.

    Returns the integral part of the given decimal, in other words, rounds towards 0. In case the result does not fit into a long, returns an error message instead.

    Requires the scale of x and y are the same.

  40. final def toString(x: BigDecimal): String

    Returns a canonical decimal string representation of x.

    Returns a canonical decimal string representation of x. The output string consists of (in left-to-right order): - An optional negative sign ("-") to indicate if x is strictly negative. - The integral part of x without leading '0' if the integral part of x is not equal to 0, "0" otherwise. - the decimal point (".") to separate the integral part from the decimal part, - the decimal part of x with '0' padded to match the scale. The number of decimal digits must be the same as the scale.

  41. def toString(): String
    Definition Classes
    AnyRef → Any
  42. final def toUnscaledString(x: BigDecimal): String
  43. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  44. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  45. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from AnyRef

Inherited from Any

Ungrouped