Floating Point Calculator

Floating-Point Converter

Convert decimal numbers to IEEE 754 floating-point binary and hexadecimal representations.Important: Decimal input is parsed as a JavaScript number, so the result is the IEEE 754 encoding of that parsed numeric value, not an arbitrary decimal-string encoding.

Last updated: March 2026 | By Patchworkr Team

What is IEEE 754 Floating-Point?

IEEE 754 is the technical standard for floating-point arithmetic used by virtually all modern computers and programming languages. It defines how decimal numbers (including very large, very small, and fractional values) are represented in binary format.

Floating-point numbers consist of three components: a sign bit (positive or negative), an exponent (determines the magnitude), and a mantissa/significand (determines the precision). This format allows computers to represent a wide range of numbers using fixed memory sizes.

The two most common formats are Float32 (single precision, 32 bits) used when memory is limited or precision requirements are moderate, and Float64 (double precision, 64 bits) used for scientific computing and when higher precision is needed.

Understanding Floating-Point Format

Float32 (Single Precision)

Sign bit (1 bit): 0 = positive, 1 = negative
Exponent (8 bits): Biased by 127, range: -126 to +127
Mantissa (23 bits): Fractional part with implicit leading 1
Range: ±1.4 × 10⁻⁴⁵ to ±3.4 × 10³⁸
Precision: ~7 decimal digits

Float64 (Double Precision)

Sign bit (1 bit): 0 = positive, 1 = negative
Exponent (11 bits): Biased by 1023, range: -1022 to +1023
Mantissa (52 bits): Fractional part with implicit leading 1
Range: ±4.9 × 10⁻³²⁴ to ±1.8 × 10³⁰⁸
Precision: ~15-16 decimal digits

Special Values

  • Zero: Exponent and mantissa all zeros (±0 possible)
  • Infinity: Exponent all ones, mantissa all zeros (±∞)
  • NaN: Exponent all ones, mantissa non-zero (undefined/error)
  • Denormalized: Exponent all zeros, mantissa non-zero (very small numbers)

Example Conversion

Convert the decimal number -12.375 to Float32:

Given:
Decimal: -12.375
Step 1:
Determine sign:
Sign = 1 (negative number)
Step 2:
Convert to binary:
12 = 1100₂, 0.375 = 0.011₂
Combined: 1100.011₂
Step 3:
Normalize:
1.100011₂ × 2³
Step 4:
Calculate exponent:
Exponent = 3 + 127 = 130 = 10000010₂
Step 5:
Extract mantissa (drop leading 1):
Mantissa = 10001100000000000000000₂
Final Result:
1 10000010 10001100000000000000000
0xC1460000

Frequently Asked Questions

Why can't computers represent 0.1 exactly?

0.1 in decimal is a repeating fraction in binary (0.000110011...), similar to how 1/3 = 0.333... in decimal. The mantissa has finite precision, so it's rounded, causing tiny errors. This is why (0.1 + 0.2) ≠ 0.3 in floating-point.

When should I use Float32 vs Float64?

Use Float32 for graphics, games, and when memory/bandwidth is limited (saves 50% space). Use Float64 for scientific computing, financial calculations, or when you need ~16 digits of precision. Most languages default to Float64.

What is the purpose of the exponent bias?

The bias (127 for Float32, 1023 for Float64) allows both positive and negative exponents to be stored as unsigned integers. This simplifies hardware comparison operations—larger bit patterns always represent larger numbers.

What does 'implicit leading 1' mean?

Normalized numbers always start with 1.xxxxx in binary, so the leading 1 is assumed and not stored, giving an extra bit of precision. The mantissa stores only the fractional part. Denormalized numbers (very near zero) don't have this implicit 1.

How do I avoid floating-point errors?

Use appropriate precision (Float64), avoid comparing for exact equality (use epsilon tolerance), be careful with accumulated errors in loops, consider decimal or rational libraries for exact decimal arithmetic (e.g., financial apps).

What is the difference between NaN values?

There are many possible NaN bit patterns (different mantissa values). Some systems use these to encode error types (quiet NaN vs signaling NaN). In practice, most languages treat all NaN values the same. NaN ≠ NaN by IEEE spec.

Can I convert negative zero to positive zero?

Technically, -0.0 and +0.0 have different bit patterns but compare as equal. Adding +0.0 converts -0.0 to +0.0. They're mainly relevant in edge cases like 1/(-0) = -∞ and 1/(+0) = +∞. Most code treats them identically.

Why use hexadecimal for floating-point?

Hexadecimal is more compact than binary (4 bits per digit) and exactly represents the bit pattern without any conversion ambiguity. It's commonly used in debugging, binary file formats, and low-level programming for precise bit-level control.

Related Tools