Math

object Math

Math object contains few shortcuts to java.lang.Math static methods.

Source
__.scala
class java.lang.Object
trait scala.Matchable
class Any

Member

trait Average[A]

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
trait Average[A]

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
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
opaque type BigInteger

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
opaque type Format
type Ordering[A] = scala.math.Ordering[A]

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
abstract class Rounding
abstract class Rounding
trait Sum[A]
Source
Sum.scala

Def

inline def ceil(v: Double): Double
Source
__.scala
inline def floor(v: Double): Double
Source
__.scala
inline def log10(v: Double): Double
Source
__.scala
inline def pow(a: Double, b: Double): Double
Source
__.scala