Suggestion for 2.5

new topic     » topic index » view thread      » older message » newer message

Rob:
When crunching numbers, sometimes one gets a "division by zero" error. In
such cases, perhaps the useful thing to do is assign "infinite" to the
result (I mean the IEEE standard infinite), so that if you use he result as
a divisor, the new result will be zero. The following are the results for
zero division I propose:
1 / 0 = inf
-1 / 0 = -inf
0 / 0 = 1
inf / 0 = inf
-inf / 0 = -inf
inf / inf = 1
-inf / inf = -1
inf / -inf = -1
-inf / -inf = 1
1 / inf = 0
-1 / inf = 0
1 / -inf = 0
-1 / -inf = 0

and the logical results for addition, subtraction and multiplication.
Please correct me if I'm wrong: I think you are checking for a zero divisor
*before* you perform the actual division, and so this proposal wont add any
overhead in the case of a divisor being zero. I don't know how are you
handling the case of infinite IEEE numbers. In any case, I'd avoid getting a
nan (not a number) result.
In order to be alerted of an error as soon as possible, like Eu does now, it
would be useful to enable or not this variation by means of a *with* or
*without* option, lets say: without zero_division.
Regards.

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu