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
Stream(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
Real value
Real value
Returns real value standing behind the opaque type.
This is a zero cost call.
- Inherited from
- _methods
- Source
- Base.scala
Round to decimal
Round to decimal
Rounds current value to specified decimal position of fractional value
- Source
- BigDecimal.scala