Skip to content

1.13.0

Compare
Choose a tag to compare
@leif-ibsen leif-ibsen released this 22 May 08:12
· 9 commits to master since this release

New in release 1.13.0:

  1. A new BFraction constructor from a string representation

    public init?(_ x: String)

for example

BFraction("3.1415") // = 6283 / 200
BFraction("123E-3") // = 123 / 1000
BFraction("abc") // = nil
  1. A new BFraction 'mod' method to compute the value modulo an integer

    public func mod(_ m: BInt) -> BInt?
    public func mod(_ m: Int) -> Int?

    for example

    BFraction(13, 3).mod(5) // = Optional(1) because 3^(-1) mod 5 = 2 and (13 * 2).mod(5) = 1

    Returns nil if the denominator and modulus are not coprime

  2. The BFraction method 'asDecimalString' has a new API

    public func asDecimalString(precision: Int, exponential: Bool = false) -> String

    where precision is the number of significant digits
    and exponential determines whether to use exponential or plain notation. For example

    BFraction(712, 11001).asDecimalString(precision: 5, exponential: false) // = "0.064721"
    BFraction(712, 11001).asDecimalString(precision: 5, exponential: true ) // = "6.4721E-2"

  3. A new static BFraction method 'bernoulliSequence'

    public static func bernoulliSequence(_ n: Int) -> [BFraction]

BFraction.bernoulliSequence(n) computes the n even indexed Bernoulli numbers B(0), B(2) ... B(2 * n - 2)
This is much faster than computing the same numbers individually.