Changes

Jump to: navigation, search

C Sharp Variables and Constants

927 bytes added, 18:50, 11 January 2008
C# Floating Point Variables
<td>double<td>16 bytes<td>5.0 * 10<sup>-324</sup> to 1.7 * 10<sup>308</sup><td>15 - 16 digits</td>
</table>
 
It is important to note that float and double variables cannot be used as counting variables (for example in looping constructs).
 
== The C# Decimal Variable Type ==
 
Both the integer and floating point families of C# variable types have some limitations. Integers can only handle whole numbers, resulting in the fractional part of a value being stripped off. Floats, on the other hand, have problems with rounding accuracy. Clearly the best of both worlds is sometimes needed and to address this requirement the ''decimal'' variable type is provided. The ''decimal'' type is a compromise between integers and float variable types in that it can store fractional parts of a value and provide exact values in computations.
 
The ''decimal'' variable type is cable of holding values in the range 10<sup>-28</sup> all the way up to 10<sup>28</sup> with none of the rounding problems associated with floating point variable types.

Navigation menu