Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

convert from Number to BINARY_DOUBLE preserve first 17 digits in mantissa?

temAug 24 2012 — edited Aug 29 2012
I'm using a third party (Matlab) program to write data to an Oracle 11.2 database. This third party uses oracles ojdbc6.jar thin driver, but does not support binary_double data types (although it supports the "double" data type used by other databases).

http://www.mathworks.com/help/toolbox/database/ug/bre04qw-1.html

I have a database table with a column that is binary_double, and I need to fill it with data from Matlab that is Matlab data type double (both are based on IEEE 754). After experimenting with the Matlab product, I learned that the data range possible (saving a double variable in Matlab to binary_double column in Oracle) obeys the Number data type. That is, I can only successfully transfer values between 1e-130 and 1e126.

Thus, I suspect that this third party program is using a statement like:

cs.registerOutParameter(1, Types.DOUBLE);

instead of

cs.registerOutParameter(1, OracleTypes.BINARY_DOUBLE);

which I guess causes Oracle database to convert the Matlab double data type into Oracle Number data type, then it converts this to binary_double to store it in the table.

My question is, through this process, will the first 17 significant digits (which are the only digits that matter in a double or binary_double data type) be preserved in the conversion process, so that these 17 decimal digits as shown in Matlab double variable always appear the same in the database table?

I'm guessing that since Number data type precision is 38, that this should be true, because 17 is less than 38. There might be some conversion errors in the last few digits, says digits 34 to 38, which shouldn't affect anything since double only uses the first 17 digits. But I don't have any visibility into what Oracle is doing. Hoping someone can help me understand if I may see some loss of precision (e.g. whether the first 17 decimal digits may change during this conversion process).

Of course, I'll be reading data out of the binary_double using a similar process but in reverse, so the JDBC driver will read data from the table that causes the binary_double value to convert to Number then back to double in Matlab. Same question applies.

Edited by: tem on Aug 24, 2012 9:16 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 26 2012
Added on Aug 24 2012
54 comments
3,314 views