* Round to nearest, ties to even – rounds to the nearest value; if the number falls midway it is rounded to the nearest value with an even (zero) least significant bit, which occurs 50% of the time; this is the default algorithm for binary floating-point and the recommended default for decimal
* Round to nearest, ties away from zero – rounds to the nearest value; if the number falls midway it is rounded to the nearest value above (for positive numbers) or below (for negative numbers)
jtuchel wrote:... and again.
Since I thought this must be my fault and I am surely missing something, I decided to ask Wikipedia. What I've found is this page:
"< relevantDecimals: iOf Integer, ^iOf Float>"
"Given a float, return and round it to the given number of relevant decimals
Since the IBM ST roundTo: returns *wrong* numbers like
(0.35 * 1.5) roundTo: 0.01 -> 0.52
(0.35 * 1.5) preciseRoundTo: 2 -> 0.53
(0.35 * 1.5) Pocket Calculator -> 0.53"
| precision |
precision := (relevantDecimals + 1) powerOfTen.
^10.0 * ((self * precision + (self sign * 5.01)) * 0.1) truncated /
Users browsing this forum: No registered users and 1 guest