Category talk:Wren-big: Difference between revisions

→‎Source code: Rewrote BigRat.toFloat and toMixedString methods which were buggy previously.
(→‎Source code: Fixed bug and aligned BigRat.pow with Rat.pow method.)
(→‎Source code: Rewrote BigRat.toFloat and toMixedString methods which were buggy previously.)
Line 2,014:
// Converts the current instance to a Num where possible.
// Will probably lose accuracy if the numerator and/or denominator are not 'small'.
toFloat { Num_n.fromString(thistoNum / _d.toDecimal(14))toNum }
 
// Converts the current instance to an integer where possible with any fractional part truncated.
Line 2,072:
// Returns a string represenation of this instance in the form "i_n/d" where 'i' is an integer.
toMixedString {
var qsign = _n.isNegative /? _d"-" : ""
var rnn = _n % _d.abs
ifvar (r.isNegative) rq = -rnn / _d
return q.toString + "_" +var r.toString += "/"nn +% _d.toString
return sign + q.toString + "_" + r.toString + "/" + _d.toString
}
 
9,476

edits