# Forcing divisions to be a machine-precision floating point divisions instead of multiplication by inverse

I want to imitate machine-precision, de facto IEEE division on Mathematica. On my quick trials I find this surprisingly hard to accomplish, since Mma rewrites a / b as a (b^-1) and these are not identical on finite-precision math.

For an explicit example, consider the following:

49. / 49. // FullForm


0.9999999999999999

EDIT: As @J.M. points out, this works:

Divide[49., 49.] // FullForm


1.

... but if I do the following, for instance, the finite-precision multiplication by inverse is seen again:

Divide[x, 49.] // FullForm


Times[0.02040816326530612, x]

How would I implement a "use native (IEEE) division semantics on machine-precision arguments of this division, even later down the evaluation chain" operation instead of Mma being too clever for its' own sake?

EDIT: In this specific case I'm not interested in other IEEE semantics, for instance strict order of operations (a + b + c is not the same as c + b + a!). I just want divisions to stay as divisions, which may be a bit of a half-way goal, but sounds more feasible to implement that the whole shebang.

• Divide[49., 49.]? (I think this was discussed before.) – J. M. will be back soon Mar 13 at 9:21
• @J.M.isslightlypensive Hmmh... maybe I should rephrase my question somehow. It would seem that the "expected" IEEE behaviour is seen only in the case the computation can be completed with supplied arguments, otherwise it reverts to the a (b^-1) expansion very eagerly... – kirma Mar 13 at 9:29
• The previous question: mathematica.stackexchange.com/questions/161716 – Coolwater Mar 13 at 11:53

You can define your own divide function:

divide[a_Real, b_Real] := Divide[a, b]
MakeBoxes[divide[a_, b_], StandardForm] := MakeBoxes[Divide[a, b], StandardForm]


Then:

divide[49., 49.]


1.

And:

r = divide[x, 49.]
r /. x->49.


x/49.

1.

Some more work is needed to define how divide` works with other arithmetical operations.