commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <gil...@harfang.homelinux.org>
Subject Re: [jira] Issue Comment Edited: (MATH-475) MathUtils.equals(double, double, double) does not agree with Javadoc
Date Sun, 16 Jan 2011 01:32:21 GMT
Hi.

On Sat, Jan 15, 2011 at 12:48:45PM -0500, Phil Steitz (JIRA) wrote:
> 
>     [ https://issues.apache.org/jira/browse/MATH-475?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12982118#action_12982118
] 
> 
> Phil Steitz edited comment on MATH-475 at 1/15/11 12:48 PM:
> ------------------------------------------------------------
> 
> Very interesting example.  How do you come up with this stuff, Sebb?  :)
> 
> I tend to agree with Gilles' view that if if a and b are not distinguishable as doubles,
we don't really have any confidence in the value of abs(a - b), so the short-circuit in the
current code is better.  I would say just update the javadoc to make say something like
> 
> "Returns true if the values are indistinguishable as doubles or the difference between
them is within the range of allowed error (inclusive)."
> 
>       was (Author: psteitz):
>     Very interesting example.  How do you come up with this stuff, Sebb?  :)
> 
> I tend to agree with Gilles' view that if if a and b are not distinguishable as doubles,
we don't really have any confidence in the value of abs(a - b), so the short-circuit in the
current code is better.  I would say just update the javadoc to make say something like
> 
> "Returns true if there is no double value strictly between the arguments or the difference
between them is within the range of allowed error (inclusive)."

Just to be sure that we agree on the semantics of "equals": The latter
description ("there is no double value strictly between the arguments")
seems more representative of the code. Indeed, 2 successive floating point
numbers _are_ distinguishable, but "equals" will nevertheless return true on
the ground that any real number within the interval could be mapped to
either of the two floating point numbers.


Gilles

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message