Category talk:Wren-big: Difference between revisions

Added BigRat.round(digits) method.
(→‎Source code: Added BigRat.cube, tweaked sqrt and cbrt methods.)
(Added BigRat.round(digits) method.)
Line 29:
There are also separate methods to enable you to to generate a BigRat from a Rat object, from a string in rational form (i.e. "n/d"), from a mixed string (e.g. "1_2/3") from a decimal string or value (e.g. "1.234") or from a Num.
 
As rational numbers can easily be created from or displayed as decimal numbers, there seems little point in adding a BigDecimal class to the module as well other than to limit precision. However, the ''round(digits)'' method can be used for this purpose when performing a series of calculations.
 
;General observations
Line 1,723:
}
return (this + BigRat.half).floor
}
 
round(digits) { // rounds to 'digits' decimal places
if (digits == 0) return round
return BigRat.fromDecimal(toDecimal(digits))
}
 
9,485

edits