Ethereum: Understanding Storage Requirements for Decimal Numbers in MS SQL

When it comes to storing data in a database, choosing the right storage type is crucial. In this article, we will look at Ethereum’s decimal storage requirements, specifically in Microsoft SQL Server (MS SQL), and review the GAAP rates for money.
Memory Requirements for Decimal Numbers: A Brief Overview
To understand Ethereum’s decimal storage requirements in MS SQL, let’s first clarify what a decimal number is. In mathematics, a decimal number is a number represented as a fraction with an infinite number of digits after the decimal point (for example, 0.5 or 3.14159). This means that when you save money, you must represent it using fractions.
In MS SQL, the GAAP standard for money specifies decimal (13,4). This format includes:
- A single character “M” representing a currency unit
- Three digits after the decimal point (“13”) indicating the fractional portion of the number
- Four digits after the decimal point (“4”) to represent the thousands place
This decimal format is commonly used in financial applications and ensures precision when handling large amounts of money.
Why Decimal (13,8) May Not Be Preferred
While GAAP (13,4) numbers are often used to store money, some might argue that using decimal (13,8) may be more intuitive or flexible. However, there is a good reason to prefer the latter option:
- Fractional Precision: MS SQL provides fractional precision in its decimal data types, including decimal (18,2). This allows you to store and modify complex financial calculations with greater precision.
On the other hand, GAAP (13,4) quotes are limited to 12 decimal digits or less, which can make it difficult to accurately represent some financial concepts.
Conclusion
In summary, when storing funds in MS SQL for Ethereum, using the standard GAAP (13,4) quotes is the recommended approach. This format ensures accurate representation of monetary values and provides a high degree of precision for complex calculations. While decimal (13,8) may seem more intuitive at first glance, it lacks fractional precision, making it less suitable for financial applications.
To give you a better idea, here is an example of how MS SQL would store the value 3.14159265358979323846 using both formats:
GAAP Quotes (13.4)
| Decimal Value | Fractional Representation |
| — | — |
| 3.14159265… | 0.00000000 |
Decimal(18,2)
| Decimal Value | Fractional Representation |
| — | — |
| 3.14159265358979323846… | 0.000000000000000001 |
As you can see, the decimal representation is more precise and accurate when you use MS SQL’s fractional precision features.
I hope this article has given you a comprehensive understanding of the decimal storage requirements in MS SQL for Ethereum. If you have any further questions or concerns, feel free to ask!