3

SQL-92 says:

         16)For the <exact numeric type>s DECIMAL and NUMERIC:

            a) The maximum value of <precision> is implementation-defined.
              <precision> shall not be greater than this value.

And yet it's 38 in Oracle, MS SQL Server, PostgreSQL, Snowflake, Teradata. Only MySQL and DB2 are different, allowing up to 65 and 31 significant digits respectively. I guess it's because a 128 bits integer can guarantee 38 decimal digits of precision, but how did almost everyone agree on using a 128 bits integer for storing the mantissa?

2
  • That 128 bit to 38 decimals precision makes perfect sense. Popular binary types are 8, 16, 32, 64 and 128 bits long. I do not know of practical implementations for 256 and up so folks choosing the maximum for representing high precision numbers is to be expected and hardly a coincidence. The other numbers do raise some interesting questions though. 65 may map to 192 bits and 31 possibly to 80. Wikipedia has a convenient page related to this: en.wikipedia.org/wiki/Power_of_two . Jun 6, 2023 at 11:28
  • There's decimal128, which supports 34 significant digits. I know it's much newer than most of these systems, but it allows the whole number to fit into 128 bits, not just the mantissa.
    – Alexey
    Jun 13, 2023 at 12:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.