macroverse icon indicating copy to clipboard operation
macroverse copied to clipboard

RealMath.fromReal truncates, and would be more usable if it rounded

Open clexmond opened this issue 7 years ago • 7 comments

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");
}

clexmond avatar Jan 25 '18 19:01 clexmond