[ 
https://issues.apache.org/jira/browse/MATH-1083?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13856600#comment-13856600
 ] 

Luc Maisonobe commented on MATH-1083:
-------------------------------------

0/0 is also the limit of x/0 when x>0 converges towards 0+, and in this case 
the result should be POSITIVE_INFINITY.
0/0 is also the limit of x/0 when x<0 converges towards 0-, and in this case 
the result should be NEGATIVE_INFINITY.

These two cases, plus the case pointed out be Sebb, plus the case pointed out 
by Andrew show that 0/0 is a very special case and no single value can be 
arbitrarily fixed for it. This is the reason why, when you deal with floating 
points numbers 0.0/0.0 is NaN (whereas x/0 is not NAN but either  
POSITIVE_INFINITY or NEGATIVE_INFINITY according to the sign of a non-zero x).

So I am reluctant to change the behaviour we have now: 0/0 is not defined.

In order to fix your problem, do you have some outside way to determine if 
either the numerator or the denominator appears to be almost 0 but has at least 
a sign? In this case, you may be able to handle this special condition in your 
calling application.

> Fraction - Allow zero denominator if numerator is also zero
> -----------------------------------------------------------
>
>                 Key: MATH-1083
>                 URL: https://issues.apache.org/jira/browse/MATH-1083
>             Project: Commons Math
>          Issue Type: Improvement
>    Affects Versions: 3.1
>            Reporter: Andrew Brampton
>            Priority: Minor
>              Labels: Fraction
>
> The Fraction constructor rejects a denominator of zero. However, while trying 
> to parse some Strings generated by another program, I encountered a fraction 
> "0/0". I would say that's ambiguous as to if that's valid, but some people 
> would agree the answer is zero.
> So, would it be possible to allow a zero denominator if the numerator is also 
> zero. I'd be happy to provide a patch.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to