Category talk:Wren-big: Difference between revisions
→Source code: Added BigRat.cube, tweaked sqrt and cbrt methods.
(→Source code: Added BigRat.cbrt method.) |
(→Source code: Added BigRat.cube, tweaked sqrt and cbrt methods.) |
||
Line 1,754:
// Returns the square of the current instance.
square { BigRat.new(_n * _n , _d *_d) }
// Returns the cube of the current instance.
cube { square * this }
// Returns the square root of the current instance to 'digits' decimal places.
Line 1,763 ⟶ 1,766:
digits = digits + 5
var powd = BigInt.ten.pow(digits)
var sqtd = (powd.square * _n / _d).
return BigRat.new(sqtd, powd)
}
Line 1,778 ⟶ 1,781:
digits = digits + 5
var powd = BigInt.ten.pow(digits)
var cbtd = (powd.cube * _n / _d).
return BigRat.new(cbtd, powd)
}
|