[
https://issues.apache.org/jira/browse/DERBY-2447?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12702042#action_12702042
]
Knut Anders Hatlen commented on DERBY-2447:
-------------------------------------------
Another alternative is to write a helper method which inspects the integer
representation of the floating point value
private static boolean isNegativeZero(double d) {
// If the most significant bit (sign bit) is 1 and the rest are 0,
// we have a negative zero.
return Double.doubleToRawLongBits(d) == 0x8000000000000000L;
}
and
if (isNegativeZero(v)) {
v = 0.0f;
}
This has the additional advantage of only matching values that actually are
negative zero.
Both approaches (comparing to -0.0f and using the helper method) appear to make
the test program print 0.0 consistently.
I don't find anything in
http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3
indicating that there is something wrong with the current implementation of
normalizeREAL() and normalizeDOUBLE(), so I'll file a bug against the JVM, at
least to get a verification of whether or not it is a bug.
JVM bug or not, both of the suggested workarounds will make the code clearer,
so I guess changing the Derby code wouldn't make any harm.
> ejbql and floattypes in
> org.apache.derbyTesting.functionTests.tests.lang.LangScripts intermittently
> fails with 'expected:<[0.0 ] > but was:<[-0.0] '
> -------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-2447
> URL: https://issues.apache.org/jira/browse/DERBY-2447
> Project: Derby
> Issue Type: Bug
> Components: Regression Test Failure
> Affects Versions: 10.3.1.4
> Environment: OS: Red Hat Enterprise Linux AS release 4 (Nahant Update
> 3) 64bits - Linux 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:56:28 EST 2006 GNU/Linux
> JVM: Sun Microsystems Inc. 1.5.0_07-b03
> OS: Solaris 10 6/06 s10s_u2wos_09a SPARC 64bits - SunOS 5.10 Generic_118833-17
> JVM: Sun Microsystems Inc. - 1.5.0_07-b03
> Reporter: Ole Solberg
> Priority: Minor
> Attachments: Normalize.java
>
>
> Seen intermittently on Linux since 2007-02-27.
> Seen on Solaris 2007-03-12.
> <signature>
> ejbql(org.apache.derbyTesting.functionTests.tests.lang.LangScripts)junit.framework.ComparisonFailure:
> Output at line 454 expected:<[0.0 ] > but was:<[-0.0] >
> at
> org.apache.derbyTesting.functionTests.util.CanonTestCase.compareCanon(CanonTestCase.java:100)
> at
> org.apache.derbyTesting.functionTests.util.ScriptTestCase.runTest(ScriptTestCase.java:124)
> at
> org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:80)
> at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
> at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
> at junit.extensions.TestSetup.run(TestSetup.java:25)
> </signature>
> <signature>
> floattypes(org.apache.derbyTesting.functionTests.tests.lang.LangScripts)junit.framework.ComparisonFailure:
> Output at line 1823 expected:<[0.0 ] > but was:<[-0.0] >
> at
> org.apache.derbyTesting.functionTests.util.CanonTestCase.compareCanon(CanonTestCase.java:100)
> at
> org.apache.derbyTesting.functionTests.util.ScriptTestCase.runTest(ScriptTestCase.java:124)
> at
> org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:80)
> at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
> at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
> at junit.extensions.TestSetup.run(TestSetup.java:25)
> </signature>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.