BigDecimal

opaque type BigDecimal

Big BigDecimal

BigDecimal is an opaque value holding java.math.BigDecimal

BigDecimal is used for really large floating point calculations

 // Calculate number Pi using Nilakantha series

 ~~(2.0.Big)
   .unfold(_.last + 4)
   .takeFirst(1000) // the more - the better
   .map(v => (4.0.Big / (v * (v + 1) * (v + 2)) - 4.0.Big / ((v + 2) * (v + 3) * (v + 4))))
   .fold(3.0.Big)(_ + _)
   .tp

 // Prints: 3.1415926535585900763679167025419016466613791096007613231066955478
Source
BigDecimal.scala

Def

@scala.annotation.targetName("remainder")
inline def %(inline v: Double | BigDecimal): BigDecimal
@scala.annotation.targetName("multiply")
inline def *(inline v: Double | BigDecimal): BigDecimal
@scala.annotation.targetName("plus")
inline def +(inline v: Double | BigDecimal): BigDecimal
@scala.annotation.targetName("minus")
inline def -(inline v: Double | BigDecimal): BigDecimal
@scala.annotation.targetName("divide")
inline def /(inline v: Double | BigDecimal)(using inline r: Math.Rounding): BigDecimal
@scala.annotation.targetName("less")
inline def <(inline v: Double | BigDecimal): Boolean
@scala.annotation.targetName("lessOrEqual")
inline def <=(inline v: Double | BigDecimal): Boolean
@scala.annotation.targetName("greater")
inline def >(inline v: Double | BigDecimal): Boolean
@scala.annotation.targetName("greaterOrEqual")
inline def >=(inline v: Double | BigDecimal): Boolean
inline def Double: Double
inline def Number: java.math.BigDecimal
inline def real: java.math.BigDecimal

Real value

Real value

Returns real value standing behind the opaque type

Inherited from
_methods
Source
Type.scala
inline def roundDecimal(v: Int)(using r: Math.Rounding): BigDecimal
inline def sign: Int