Category talk:Wren-big: Difference between revisions

(→‎Source code: BigRat.fromDecimal method can now deal with scientific notation.)
(→‎Source code: Bug fix.)
Line 1,559:
if (zfill.type != Bool) Fiber.abort("Zfill must be true or false.")
var qr = _n.divMod(_d)
var intPart = qr[0].toString
if (this.isNegative && qr[0] == 0) intPart = "-" + intPart
var rem = BigRat.new(qr[1].abs, _d)
// need to allow an extra digit if 'rounding' is true
Line 1,570 ⟶ 1,568:
if (finalByte >= 53) { // last character >= 5
decPart = (BigInt.new(decPart) + 5).toString
if (digits == 0) qr[0] = isNegative ? qr[0].dec : qr[0].inc
}
decPart = decPart[0...-1] // remove last digit
Line 1,580 ⟶ 1,579:
}
if (digits < 1) decPart = ""
var intPart = qr[0].toString
if (this.isNegative && qr[0] == 0) intPart = "-" + intPart
if (decPart == "") return intPart + (zfill ? "." + ("0" * digits) : "")
return intPart + "." + decPart + (zfill ? ("0" * (digits - decPart.count)) : "")
}
 
9,476

edits