Category talk:Wren-math: Difference between revisions
→Source code: Removed all methods which are now in core library as well as type aliases. Added Int.isSquare and Int.isCube methods.
(→Source code: Added segmented sieve method.) |
(→Source code: Removed all methods which are now in core library as well as type aliases. Added Int.isSquare and Int.isCube methods.) |
||
Line 7:
static e { 2.71828182845904523536 } // base of natural logarithms
static phi { 1.6180339887498948482 } // golden ratio
static ln2 { 0.69314718055994530942 } // natural logarithm of 2
static ln10 { 2.30258509299404568402 } // natural logarithm of 10
//
static exp(x) { e.pow(x) }▼
static log10(x) { x.log/ln10 } // Base 10 logarithm
Line 36 ⟶ 26:
static radians(d) { d * Num.pi / 180}
static degrees(r) { r * 180 / Num.pi }
// Returns the square root of 'x' squared + 'y' squared.
Line 59 ⟶ 46:
}
}
// Round away from zero.
Line 107 ⟶ 90:
// Maximum safe integer = 2^53 - 1.
static maxSafe { 9007199254740991 }
// Returns whether or not 'n' is a perfect square.
static isSquare(n) {
var s = n.sqrt.floor
return s * s == n
}
// Returns whether or not 'n' is a perfect cube.
var c = n.cbrt.truncate
return c * c * c == n
}
// Returns the greatest common divisor of 'x' and 'y'.
Line 532 ⟶ 527:
return itob_(btoi_(b1) ^ btoi_(b2))
}
}</lang>▼
▲</lang>
|