Math
Math object contains few shortcuts to java.lang.Math static methods.
- Source
- __.scala
Member
Given instance of Math.Average for a particular type, enables this type to participate in calculating average value for streamed instances.
By default Double, Float and opaque numericals of Double and Float allow averaging.
- Source
- Average.scala
Given instance of Math.Average for a particular type, enables this type to participate in calculating average value for streamed instances.
By default Double, Float and opaque numericals of Double and Float allow averaging.
- Source
- Average.scala
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
Big Integer
BigInteger is an opaque value holding java.math.BigInteger
BigInteger is used for really large integer calculations
val max: BigInteger = Stream(58).repeat(35).foldAs(1.Big)(_ * _)
"Largest Bitcoin address= " + max + ", digits=" + max.toString.length tp()
val TenB = 10.Big * 1000 * 1000 * 1000
val YearSecs = 60.Big * 60 * 24 * 365
"Suppose, there is 10 billion computers in the world capable counting 10 billion numbers per second each" tp()
" Together they will count " + (TenB * TenB) + " in a second" tp()
" Together they will count " + (TenB * TenB * YearSecs) + " in a year" tp()
" Together they will count " + (TenB * TenB * YearSecs * TenB) + " in 10 billions years - the 'Age of Universe'" tp()
"It is required " + (max / ((TenB * TenB * YearSecs * TenB))) + " 'Ages of Universe'" tp()
"for all todays computers together to just simply count all Bitcoin adresses" tp()
// Output ****************************************************************************************************************
Largest Bitcoin address= 52478302028992644968172978478148648556151605660894866578604032, digits=62
Suppose, there is 10 billion computers in the world capable counting 10 billion numbers per second each
Together they will count 100000000000000000000 in a second
Together they will count 3153600000000000000000000000 in a year
Together they will count 31536000000000000000000000000000000000 in 10 billions years - the 'Age of Universe'
It is required 1664076041000527808478341 'Ages of Universe'
for all todays computers together to just simply count all Bitcoin adresses
- Source
- BigInteger.scala
Scalqa Ordering is an alias to scala.Ordering. Both can be used interchangeably.
Scalqa Ordering has a new set of methods provided as extensions.
- Source
- Ordering.scala