• Post Reply Bookmark Topic Watch Topic
  • New Topic

Storing floats and doubles  RSS feed

 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I understand it, Oracle stores floats and doubles as X.Y where X is the number of digits prior to the decimal point and Y is the number of decimal places after it. However, Java uses the IEEE 754 which stores: a sign bit, exponent, and fraction. How do you store these numbers without losing percision?
--Mark
 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found http://www.csis.gvsu.edu/GeneralInfo/Oracle/java.920/a96654/ref.htm#1005984, which states:

IEEE 754 Floating Point Compliance
The arithmetic for the Oracle NUMBER type does not comply with the IEEE 754 standard for floating-point arithmetic. Therefore, there can be small disagreements between the results of computations performed by Oracle and the same computations performed by Java.
Oracle stores numbers in a format compatible with decimal arithmetic and guarantees 38 decimal digits of precision. It represents zero, minus infinity, and plus infinity exactly. For each positive number it represents, it represents a negative number of the same absolute value.
It represents every positive number between 10-30 and (1 - 10-38) * 10126 to full 38-digit precision.


How do other organizations deal with this?
--Mark
 
SJ Adnams
Ranch Hand
Posts: 925
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you decide how much precision you need.
here the most precision is with exchange rates number(16,6)
I guess for scientific apps you may need more (especially with frequencies etc)
even so, 38 digits should cover all requirements!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!