Bug#673765: dom4j FTBFS with openjdk-7

Niels Thykier niels at thykier.net
Wed May 23 08:48:26 UTC 2012


On 2012-05-23 10:19, James Page wrote:
> Hi Niels
> 
> On 23/05/12 07:27, Niels Thykier wrote:
>> However, I must admit I am a bit concerned in the use of of "!="
>> with reals (floats/doubles)[0].  To my understanding (in at least
>> C/C++) that is very likely to always be true due to even minor
>> rounding errors[1]. Presumably this is why upstream used
>> "Math.round" in the first place. It is possible that it only apply
>> to expressions (and not stored values in variables) or Java handles
>> this better, but in this case, I believe a comment in the code
>> documenting this assertion would be prudent.
> 
> I had the same concern when writing this patch but reading into this
> in a bit more detail I decided that this was actually OK for the
> following reason.
> 
> The priority (see [0]) is always one of four values:
> 
>  -0.25
>  0.5
>  0.0
>  -0.5
> 
> I did a quick check and all four of these values can be represented
> accurately in Java (this is not true of all float/double literals).
> 
> I'll update the patch with an appropriate comment to this effect.
> 
> Cheers
> 
> James
> 
> [0] http://www.w3.org/TR/xslt11/#conflict

Revisiting this, couldn't we use Double.compare(double, double) for
this?  This way we should be safe from changes (if any) in how doubles
are handled in the future as well as any changes to the standard
(possible exceptions include allowing the use "NaN" or "INF" values).

~Niels






More information about the pkg-java-maintainers mailing list