Varying difference between 1.0 and 1

Issue #128 resolved
Artur Rataj created an issue

This works:

((1 - ((i * 1.0) / 10)) / (1.0 - ((i * 1.0) / 10))) --> 1

This doesn't:

i * ((1 - ((i * 1.0) / 10)) / (1.0 - ((i * 1.0) / 10))) --> (i * (1.0 - 0.1 * i)) / (1.0 - 0.1 * i)

If 1.0 is changed to 1 in the latter, it works too:

i * ((1 - ((i * 1) / 10)) / (1 - ((i * 1) / 10))) --> i

Thus, 1 and 1.0 sometimes are treated the same, sometimes not.

Comments (5)

  1. Artur Rataj reporter

    Or, it might be just a coincidence, as this equation:

    (1 - ((1 - (i/10)) / (1 - (i/10)))) --> 1+(-1+i/10)/(1-i/10)

    is not simplified to zero for both 1s and 1.0s.

  2. Axel Kramer repo owner

    I changed the behaviour a bit to be more like other CAS for these cases in commmit 26680c7

    The 1 and 1.0 difference occurs, if sometimes the IExpr#isOne() method is used which gives true for both 1 and 1.0, and sometimes an #equals() compare was used which distinguishes between 1 and 1.0

  3. Log in to comment