EditSafely

Convert Float to Hexfloat

Create a hexfloat number from a floating-point number. Runs entirely in your browser, so your data never leaves your device.

0 chars · 0 lines

Output

The result appears here as you type.

How to use Convert Float to Hexfloat

  1. 1. Enter a floating-point number. Type a decimal value such as 12 or 0.375 into the input pane. Negative numbers and scientific notation are accepted just as a C compiler would accept them.
  2. 2. Read the hexfloat anatomy. The output uses C99 syntax: 0x1.8p+3 means a mantissa of 1.5 in hex scaled by two to the third power. Because the mantissa is written in base 2 fractions, the value is exact.
  3. 3. Copy the literal. Copy the hexfloat and paste it into C, C++, Java or printf %a contexts where you want a constant that round-trips without any decimal rounding.

When to use Convert Float to Hexfloat

Convert Float to Hexfloat produces the %a style literal that represents a floating-point value exactly, with no decimal approximation. Numeric library authors, compiler engineers and anyone chasing one-ulp bugs use hexfloats because they eliminate the ambiguity of decimal constants.

  • Pinning exact constants in numeric code. A math library needs a polynomial coefficient reproduced bit for bit on every platform. Convert the value to a hexfloat literal so no compiler's decimal parsing can perturb it.
  • Reading printf %a debug output. You sprinkled %a into logging to capture exact values, and now need to generate matching literals for a regression test. This tool converts the values your test should compare against.
  • Reporting compiler rounding bugs. A bug report about constant folding is far more convincing with hexfloats, since both sides see the exact bits. Convert your inputs and expected outputs before filing the issue.
  • Teaching binary fractions. Showing that 0.375 is exactly 0x1.8p-2 while 0.1 produces an unwieldy repeating mantissa is a memorable demonstration of which decimals binary floating point can represent.

Examples

Twelve

Input

12

Output

0x1.8p+3

Half

Input

0.5

Output

0x1p-1

About the Convert Float to Hexfloat tool

Convert Float to Hexfloat runs as plain JavaScript in your browser tab, with no server behind it. Create a hexfloat number from a floating-point number. Whatever you put in stays on your device from start to finish.

The tool is part of EditSafely's Hex Tools section, 108 single-purpose utilities built around the same idea: open the page, get the result, keep your data to yourself.

There is nothing to configure. Provide the input and the result appears on its own. 2 worked examples further down the page show exactly what the tool produces for real inputs.

That local-first design has practical benefits beyond privacy. The tool keeps working on a flaky connection once the page has loaded, results are instant because nothing round-trips to a server, and it is safe to use with confidential material.

Frequently asked questions

Is Convert Float to Hexfloat free to use?

Yes, it is completely free. All 2,658 tools on EditSafely work without an account, a subscription or usage limits.

Is it safe to paste sensitive or confidential data?

Everything happens locally. Your browser downloads the tool's code once, then does all the processing itself; nothing you enter is transmitted, stored or logged. You can even go offline after the page loads and it will still work.

How much text can I process at once?

There is no fixed limit. Because the work happens on your own device rather than on a shared server, the practical ceiling is your machine's memory, which comfortably handles inputs far larger than typical online tools allow.

Do I need to sign up or install anything?

No. The tool works in any modern browser on desktop, tablet or phone. There is no account to create, no extension to add and no software to install.

How do I use the result?

The output panel has a one-click copy button, and you can keep refining the input while you work; the result updates in place as you type.