- The decimal data type is used for storing very accurate numbers.Ablestock.com/AbleStock.com/Getty Images
Decimal data types store variables as signed 128-bit (16-byte) integers. These are scaled by a variable power of 10 which specifies the number of digits to the right of the decimal point. For example, the largest possible value of +/- 79,228,162,514,264,337,593,543,950,335 would be stored as 7.9228162514264337593543950335 with a scaling factor of 0. The scaling factor would shift the decimal until there are zero digits to the right of the decimal point. Additionally, the smallest possible value of the decimal data type is +/-0.0000000000000000000000000001 (+/-1E-28). - The number data type is used for storing very large numbers.Jupiterimages/Polka Dot/Getty Images
Number data types store variables as a 64-bit (8-byte) floating-point number. The number data types is capable of representing numbers as large as 1.79E+308 or as small as 1E-323 with 15 digits of accuracy. In addition, the number data type can represent NaN (Not a Number), positive and negative infinity, and zero. - Very large numbers should be stored using the number data type.Jupiterimages/Photos.com/Getty Images
When the project you are working on requires the storage of very large numbers but does not require a great deal of precision, you can use the number data type. This is because the number data type is capable of storing values up to 1.79E+308 while the decimal data type can only reach as high as 7.9E+28. Additionally, the number data type can store values as small as 1E-323 while the decimal data type only stores values as small as 1E-28. - Very accurate numbers should be stored using the decimal data type.Hemera Technologies/PhotoObjects.net/Getty Images
Those projects requiring the storage of very accurate numbers which are relatively small should use the decimal data type. This is because the number data type is only accurate to 15 digits. On the other hand, the decimal data type is accurate to 28 digits. This makes the decimal data type much more accurate than the number data type.
previous post
next post