Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2010
    Posts
    2

    Unanswered: C doubles, Java doubles, and Informix FLOAT

    We have two applications that write to the same Informix table.

    The column in question is declared as type FLOAT.

    Now then (and I'm more a Java guy than an Informix guy or a C guy):

    In Java, we can call setFloat(someColumn, 1.3f) on the Informix driver and insert the result. When we then look at the values in the table, we see 1.299999... . This doesn't surprise me, given the way that floats are represented in Java (using IEEE 754).

    (This also occurs if we do setDouble(someColumn, 1.3d).)

    Now, on the ESQL side, a double of 1.3 gets inserted, and when we look at the table we see exactly 1.3.

    There are so many opportunities for me to be ignorant here--what could the reasons be for this discrepancy? I am happy to be pointed to various FMs to R. :-)

    Thanks in advance,
    Laird

  2. #2
    Join Date
    Jul 2009
    Posts
    37
    Quote Originally Posted by ljnelson View Post
    Now then (and I'm more a Java guy than an Informix guy or a C guy):

    In Java, we can call setFloat(someColumn, 1.3f) on the Informix driver and insert the result. When we then look at the values in the table, we see 1.299999... . This doesn't surprise me, given the way that floats are represented in Java (using IEEE 754).
    Java does not use IEEE 754 unless you specifically tell it to!! Please see strictfp keyword When to use "strictfp" keyword in java? - Stack Overflow

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •