> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# C# float

The `float` keyword in C# represents a single-precision, 32-bit floating-point value type. It is an alias for the .NET `System.Single` struct and conforms to the IEEE 754 standard for binary floating-point arithmetic.

## Technical Specifications

* **Underlying Type:** `System.Single`
* **Memory Size:** 4 bytes (32 bits)
* **Precision:** \~6 to 9 significant decimal digits
* **Approximate Range:** ±1.5 x 10^−45 to ±3.4 x 10^38
* **Default Value:** `0.0f`

## Memory Layout

The 32 bits of a `float` are divided into three components according to IEEE 754:

1. **Sign bit:** 1 bit (0 for positive, 1 for negative)
2. **Exponent:** 8 bits (biased by 127)
3. **Mantissa (Significand):** 23 bits (representing the fractional part)

## Syntax and Initialization

By default, a real numeric literal on the right side of an assignment is treated as a `double`. To initialize a `float`, you must append the literal suffix `f` or `F`. Omitting the suffix results in a compiler error due to the lack of an implicit conversion from `double` to `float`.

```csharp theme={"dark"}
// Correct initialization using the 'f' suffix
float standardValue = 3.14f;
float negativeValue = -0.005F;

// Scientific notation
float scientificValue = 1.2e-5f; 

// Default initialization (evaluates to 0.0f)
float defaultValue = default;
```

## Special Values

The `System.Single` struct provides constants to represent special floating-point states that occur during undefined or overflow arithmetic operations.

```csharp theme={"dark"}
float zero = 0.0f;

// Evaluates to float.PositiveInfinity
float positiveInfinity = 1.0f / zero; 

// Evaluates to float.NegativeInfinity
float negativeInfinity = -1.0f / zero; 

// Evaluates to float.NaN (Not a Number)
float notANumber = zero / zero; 

// The smallest positive value greater than zero (approx 1.4e-45)
float epsilonValue = float.Epsilon; 
```

## Type Conversions

**Implicit Conversions:**
C# allows implicit conversions to `float` from any integral type (`sbyte`, `byte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, and `char`). Note that converting from 32-bit or 64-bit integers (`int`, `long`) to `float` may result in a loss of precision, though the magnitude is preserved.

```csharp theme={"dark"}
int integerValue = 16777217;
float implicitlyConverted = integerValue; 
// implicitlyConverted evaluates to 16777216.0f due to precision limits
```

**Explicit Conversions:**
Conversions from higher-precision floating-point types (`double`, `decimal`) to `float` require an explicit cast. This can result in overflow (yielding infinity) or a loss of precision.

```csharp theme={"dark"}
double doubleValue = 3.14159265358979;
float explicitlyCast = (float)doubleValue; 
// explicitlyCast evaluates to 3.1415927f
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor C# Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
