Category talk:Wren-big: Difference between revisions

Content added Content deleted
(→‎Source code: Added BigRat.roundUp method.)
(→‎Source code: Added BigInt.prevPrime method.)
Line 967: Line 967:
}
}


// Returns the previous probable prime number less than 'this' or null if there isn't one.
// Convenience version of the above method which uses 5 iterations.
prevPrime(iterations) {
if (this < BigInt.three) return null
if (this == BigInt.three) return BigInt.two
var n = isEven ? this - 1 : this - 2
while (true) {
if (n.isProbablePrime(iterations)) return n
n = n - 2
}
}

// Convenience versions of the above methods which use 5 iterations.
nextPrime { nextPrime(5) }
nextPrime { nextPrime(5) }
prevPrime { prevPrime(5) }


// Negates a BigInt.
// Negates a BigInt.