macroverse
macroverse copied to clipboard
RealMath.fromReal truncates, and would be more usable if it rounded
The following fails with RealMath.fromReal(hundred)
being 99
. And in fact the result is always off by int(1)
(i.e. 4000 * 2/40 = 199).
function testRealMath() public {
var exp = RealMath.div(RealMath.toReal(1), RealMath.toReal(40));
var hundred = RealMath.mul(exp, RealMath.toReal(4000));
Assert.equal(RealMath.fromReal(hundred), 100, "Should equal 100");
}