- float
- double
- decimal
1. Float Data Type.
float number = 10.5f;
Key Characteristics of float.
| Property | Value |
|---|---|
| Size | 4 bytes (32 bits) |
| Precision | ~6–7 significant digits |
| Range | ±1.5 × 10-45 to ±3.4 × 1038 |
| Base | Binary (base-2) |
| Speed | Very fast |
float a = 1.1f; float b = 2.2f; Console.WriteLine(a + b); // Output: 3.3000002
- A small precision loss is acceptable
- High performance is required
- Memory usage must be low
2. Double Data Type.
double number = 10.5;
Key Characteristics of double:
| Property | Value |
|---|---|
| Size | 8 bytes (64 bits) |
| Precision | ~15–16 significant digits |
| Range | ±5.0 × 10-324 to ±1.7 × 10308 |
| Base | Binary (base-2) |
| Speed | Fast (hardware-accelerated) |
double x = 0.1; double y = 0.2; Console.WriteLine(x + y); // Output: 0.30000000000000004
- You need high precision
- Performance is important
- Exact decimal accuracy is not critical
Why is double preferred over float?
float f = 1.0f / 3.0f; double d = 1.0 / 3.0; Console.WriteLine(f); // 0.33333334 Console.WriteLine(d); // 0.3333333333333333
3. Decimal Data Type.
decimal amount = 10.5m;
| Property | Value |
|---|---|
| Size | 16 bytes (128 bits) |
| Precision | 28–29 significant digits |
| Range | ±1.0 × 10-28 to ±7.9 × 1028 |
| Base | Decimal (base-10) |
| Speed | Slower than float and double |
double d = 0.1 + 0.2; decimal m = 0.1m + 0.2m; Console.WriteLine(d); // 0.30000000000000004 Console.WriteLine(m); // 0.3
Comparison Table:
| Feature | float | double | decimal |
|---|---|---|---|
| Size | 4 bytes | 8 bytes | 16 bytes |
| Precision | 6–7 digits | 15–16 digits | 28–29 digits |
| Base | Binary | Binary | Decimal |
| Performance | Fastest | Fast | Slowest |
| Accuracy | Lowest | Medium | Highest |
| Best For | Graphics, games | Scientific math | Finance, money |
Final Summary
- float → lightweight, fast, low precision
- double → balanced, default, high performance
- decimal → accurate, safe for money, slower



