title: Oracle data types: advice on choosing NUMBER versus BINARY DOUBLE?
body: <p>I'm generating a scientific application that performs a lot of number crunching in Java and C, and accuracy is critical. There is no number crunching done inside the Oracle database (it's merely used for storing variables between math computations). </p>
  
  <p>I've used double-precision data type for all of my Java and C variables, which is largely based on IEEE 754. So, the data written into the database and then read out of the database will both be from double-precision data types in either C or Java. </p>
  
  <p>What would you recommend I use to store the double-percision data in Oracle -- NUMBER or BINARY DOUBLE? </p>
  
  <p>For example, let's say I have a variable called <code>X_Java</code> that I write into the database as variable <code>X_DB</code> as a BINARY DOUBLE. If I were to read this data back into Java from the database and store it in variable <code>X_Java2</code>, would <code>X_Java</code> exactly match <code>X_Java2</code>? </p>
  
  <p>How would things change I stored <code>X_DB</code> in the database as a NUMBER? </p>
  
  <p>UPDATE 1:  Note that my benchmark for "accuracy" is how close the number read OUT OF the database is to the number that was available before being written INTO the database. </p>
  
  <p>One one hand, I'd think that if the number available before being written INTO the database is based on IEEE 754, then the data type used to store this value INSIDE the database should be an exact match if that data type was also based on IEEE 754. </p>
  
  <p>On the other hand, since a 64 bit (double precision) number can only accurately store up to 16 (sometime 17) digits of accuracy, then storing as a NUMBER in the database with 38 digits of precision should accurately map from and to double precision. One downside is that the NUMBER data type cannot store as large (or as small) values as BINARY DOUBLE.</p>
  
  <p>Thus, my posting.</p>