Difficulty: Easy
Correct Answer: 16 byte
Explanation:
Introduction / Context:
The Decimal (System.Decimal) type in C#.NET is a high-precision, base-10 numeric type designed for financial and monetary calculations where rounding errors from binary floating-point types (Single/Double) are unacceptable. Knowing its exact size helps developers reason about memory usage and precision trade-offs.
Given Data / Assumptions:
Concept / Approach:
System.Decimal is implemented as a 128-bit (16-byte) structure. Internally, it stores a 96-bit integer (significand) plus scaling information and a sign, enabling exact decimal representation for many base-10 values. This contrasts with Single (4 bytes, 32-bit) and Double (8 bytes, 64-bit) that use binary floating-point representation.
Step-by-Step Solution:
Verification / Alternative check:
You can confirm by checking sizeof(decimal) in an unsafe context or by consulting official .NET documentation indicating Decimal is 128 bits.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing Decimal with Double due to both being used for real numbers. Decimal is significantly larger (16 bytes) and optimized for base-10 precision, not scientific computation speed.
Final Answer:
16 byte
Discussion & Comments