[ 
http://issues.apache.org/jira/browse/JDO-206?page=comments#action_12360161 ] 

Erik Bengtson commented on JDO-206:
-----------------------------------

Somehow derby is not storing correct the value.  I found that derby stores 
(float)-234.23 as -234.22999572753906

Here is the stacktrace that points the place with the bug.

Thread [main] (Suspended)
        Double.isNaN(double) line: 494
        NumberDataType.normalizeDOUBLE(double) line: not available
        SQLDouble.setValue(float) line: not available
        EmbedPreparedStatement30(EmbedPreparedStatement).setFloat(int, float) 
line: not available
        NewProxyPreparedStatement.setFloat(int, float) line: 729
        FloatRDBMSMapping.setFloat(Object, int, float) line: 90
        FloatMapping(SingleFieldMapping).setFloat(PersistenceManager, Object, 
int[], float) line: 245
        ParameterSetter.storeFloatField(int, float) line: 94
        StateManagerImpl.providedFloatField(PersistenceCapable, int, float) 
line: 2420
        AllTypes.jdoProvideField(int) line: not available
        AllTypes.jdoProvideFields(int[]) line: not available
        StateManagerImpl.provideFields(int[], FieldManager) line: 2827
        UpdateRequest.execute(StateManager) line: 224
        ClassTable.update(StateManager, FieldMetaData[]) line: 2118
        RDBMSManager(StoreManager).update(StateManager, int[]) line: 780
        StateManagerImpl.flush() line: 4401
        PersistenceManagerImpl(AbstractPersistenceManager).flush() line: 3044
        NonmanagedTransaction.getConnection(boolean, boolean, boolean) line: 220
        NonmanagedTransaction.getConnection(boolean, boolean) line: 189
        
PersistenceManagerImpl(AbstractPersistenceManager).getConnection(boolean, 
boolean) line: 321
        InsertRequest.execute(StateManager) line: 168
        ClassTable.insert(StateManager) line: 2058
        RDBMSManager(StoreManager).insert(StateManager) line: 733
        StateManagerImpl.internalMakePersistent() line: 3261
        StateManagerImpl.makePersistent() line: 3234
        
PersistenceManagerImpl(AbstractPersistenceManager).internalMakePersistent(Object,
 FieldValues) line: 1061
        
PersistenceManagerImpl(AbstractPersistenceManager).makePersistent(Object) line: 
1112
        AllTypes.load(PersistenceManager) line: 269
        NotEquals(ComparisonTests).verifyDataLoaded(PersistenceManager) line: 91
        NotEquals.test() line: 184
        NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not 
available [native method]
        NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
        DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
        Method.invoke(Object, Object...) line: 585
        NotEquals(TestCase).runTest() line: 154
        NotEquals(JDO_Test).runBare() line: 204
        TestResult$1.protect() line: 106
        TestResult.runProtected(Test, Protectable) line: 124
        TestResult.run(TestCase) line: 109
        NotEquals(TestCase).run(TestResult) line: 118
        TestSuite.runTest(Test, TestResult) line: 208
        TestSuite.run(TestResult) line: 203
        BatchTestRunner(TestRunner).doRun(Test, boolean) line: 116
        BatchTestRunner(TestRunner).doRun(Test) line: 109
        BatchTestRunner.run(Test) line: 80
        BatchTestRunner.run(Class) line: 75
        NotEquals.main(String[]) line: 177


This is the code that reproduces the issue with derby

import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.types.NumberDataType;

public class FloatTest
{

    /**
     * @param args
     */
    public static void main(String[] args)
    {
        try
        {
            System.out.println(NumberDataType.normalizeDOUBLE((float)-234.23));
        }
        catch (StandardException e)
        {
            e.printStackTrace();
        }
    }

}


> JDOQL test NotEquals comparing floating point numbers
> -----------------------------------------------------
>
>          Key: JDO-206
>          URL: http://issues.apache.org/jira/browse/JDO-206
>      Project: JDO
>         Type: Bug
>   Components: tck20
>     Reporter: Andy Jefferson
>     Assignee: Erik Bengtson

>
> The current TCK test (carried over from JDO 1.0) for NotEquals, uses != 
> operator on floating point numbers. This is not a good practice, and is 
> unreliable. Its probably the case that the Equals test uses == on the same 
> content, which also is not a good idea (as noted in the latest spec). These 
> tests need reviewing and a reliable alternate strategy adopting

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to