Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 08:32, 19 August 2025 by Dylan (talk | contribs) (new: info, size, example)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The float 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 floats can represent and how they are represented in memory.

Size

A float in C# is represented by 4 bytes, or 32 bits.

They are usually accurate up to around 7 digits.

If you need more precision or larger/smaller numbers, you can instead use the double data type.

Example

float a;
float b = 539.72;
float c = (float)781; // 781.0