Skip to content

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

@clexmond

Description

@clexmond

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions