Category talk:Wren-big: Difference between revisions

(→‎Source code: Bug fix.)
(→‎Source code: Bug fix.)
Line 1,558:
if (rounded.type != Bool) Fiber.abort("Rounded must be true or false.")
if (zfill.type != Bool) Fiber.abort("Zfill must be true or false.")
var qr = _n.divMod(_d)
var rem = BigRat.new(qr[1].abs, _d)
// need to allow an extra digit if 'rounding' is true
Line 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 {
qr[0] = isNegative ? qr[0].dec : qr[0].inc
} else if (decPart.count == digits2 + 1) {
qr[0] = isNegative ? qr[0].dec : qr[0].inc
decPart = decPart[1..-1]
}
}
decPart = decPart[0...-1] // remove last digit
Line 1,578 ⟶ 1,583:
decPart = decPart.trimEnd("0")
}
if (digits < 1 || digits == 1 && decPart == "0") decPart = ""
var intPart = qr[0].toString
if (this.isNegative && qr[0] == 0) intPart = "-" + intPart
if (decPart == "") return intPart + (zfill ? "." + ("0" * digits) : "") {
return intPart + "." + decPartif (digits > 0) return intPart + (zfill ? "." + ("0" * (digits - decPart.count)) : "")
return intPart
}
return intPart + "." + decPart + (zfill ? ("0" * (digits - decPart.count)) : "")
}
 
9,476

edits