C Sharp double: Difference between revisions
From Coderwiki
More actions
new: info, size, example |
(No difference)
|
Latest revision as of 08:34, 19 August 2025
The double class in C Sharp is a data type which can store positive and negative decimal numbers in variables.
See Floating point for generic information about what doubles can represent and how they are represented in memory.
Size
edit edit sourceA double in C# is represented by 8 bytes, or 64 bits.
They are usually accurate up to around 15 digits.
If you need less precision or don't need very large/small numbers, you can instead use the float data type.
Example
edit edit sourcedouble a;
double b = 539.72;
double c = (double)781; // 781.0