If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > C doubles, Java doubles, and Informix FLOAT

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-26-10, 10:47
ljnelson ljnelson is offline
Registered User
 
Join Date: Aug 2010
Posts: 2
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
Reply With Quote
  #2 (permalink)  
Old 09-07-10, 08:57
bigcalm bigcalm is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On