Forum Stats

  • 3,874,667 Users
  • 2,266,763 Discussions
  • 7,911,935 Comments

Discussions

Is binary double not accurate?

1008271
1008271 Member Posts: 1
edited May 10, 2013 4:06PM in General Database Discussions
Our application uses an oracle 11g database. We have to store very small numbers (1.0E-200) which is too small for a normal number data type.

The alternative would be binary_double, but I read that it can be inaccurate in some cases (http://www.dba-oracle.com/plsql/t_plsql_binary_float.htm).

Is it true that values are not stored accuratly in binary_double? Are values in the range of binary_double (from 2.22507485850720E-308 to 1.79769313486231E+308) are stored accurate?

What are possible Disadvantages of binary_double?
Tagged:

Answers

  • jgarry
    jgarry Member Posts: 13,844 Gold Crown
    edited May 10, 2013 1:04PM
    Information on that domain should be viewed with a critical eye.

    It's not so much the accuracy, as programmers need to understand the precision and rounding, especially when pushing boundary conditions. See http://www.ixora.com.au/notes/numeric_datatypes.htm Edit: Yikes, I need to look at what I post more closely. See http://docs.oracle.com/cd/B28359_01/server.111/b28286/sql_elements001.htm#i140176

    Edited by: jgarry on May 10, 2013 10:03 AM
  • Welcome to the forum!

    Whenever you post provide your 4 digit Oracle version.
    >
    Our application uses an oracle 11g database. We have to store very small numbers (1.0E-200) which is too small for a normal number data type.

    The alternative would be binary_double, but I read that it can be inaccurate in some cases (http://www.dba-oracle.com/plsql/t_plsql_binary_float.htm).

    Is it true that values are not stored accuratly in binary_double? Are values in the range of binary_double (from 2.22507485850720E-308 to 1.79769313486231E+308) are stored accurate?

    What are possible Disadvantages of binary_double?
    >
    The internal format of a BINARY_DOUBLE value conforms to the IEEE standard.

    Is a 'value' stored accurately in BINARY_DOUBLE? That depends on the datatype of the 'value'.

    Floating point values ARE stored accurately in binary_double. But a non-floating point value must first be converted by Oracle to the 64 bit BINARY_DOUBLE floating point format. That conversion can cause precision to be lost.

    A 'value' such as '.1' cannot be represented exactly in binary floating-point, no matter what the precision is. So when it is converted to floating-point some precision will be lost. And if you then convert that floating-point representation back to decimal (e.g. Oracle NUMBER) you may not get exactly '.1' again.

    That is where any inaccuracy gets introduced: conversion of a number from one number system to another (e.g. decimal to binary or binary to decimal).
This discussion has been closed.