Float Validator
Check whether text is a valid floating-point number as you type it, right in your browser, without sending it anywhere.
Input
Output
No value
Guide
What is a floating-point number?
A floating-point number, or float, is a number that can have a fractional part, such as 3.14, -0.5 or 42. The name comes from the way computers store such numbers: as digits plus an exponent that moves, or floats, the decimal point. Text can show that exponent in e notation: 1.5e3 means 1.5 times 10 to the power of 3, which is 1500.
Floats hold measurements, coordinates, sensor readings and scientific data, and the numbers in JSON and CSV files. A program checks that text is a float before it converts it, so that a typo such as 3..14 gets caught.
Tool description
Type or paste a value into the Floating-point number field, and the result shows as you type: "Floating-point number is valid" or "Floating-point number is not valid". Spaces and line breaks around a pasted value are ignored.
The Decimal separator menu sets the sign between the whole part and the decimals: Dot, Comma or Arabic decimal separator (٫). It starts on the separator most people type in the language you're reading the page in. Minimum and Maximum start empty. Fill in one or both to require a value in that range, the limits included: with a maximum of 10, 10.0 passes and 10.01 fails.
Numbers that pass
The examples use Dot. With Comma or the Arabic separator, that sign takes the dot's place.
- Whole numbers and decimals, with or without a sign:
42,-0.5,+3.14 - A separator at the start or at the end:
.5,5. - E notation, with a small or capital e:
1e5,2.5E-3,-4e+2 - Leading zeros:
007.5
Numbers that fail
- The other separator:
3,14fails with Dot, and3.14fails with Comma - Thousands separators and spaces inside:
1,000,1 000 - An e with no digits after it:
1e InfinityandNaN, which some programming languages read as floats- Hexadecimal numbers:
0x1F - Arabic-Indic digits, even with the Arabic decimal separator:
٣٫١٤fails, while3٫14passes
Good to know
- Of the checks for ordinary numbers, this one accepts the most. The Decimal Number Validator rejects e notation and a separator at the end, and the Integer Validator rejects decimals.
- A few strings that aren't numbers pass: an exponent with nothing before it, such as
e5, and a sign with a lone separator, such as-.. They fail once Minimum or Maximum is filled in. - With the Arabic decimal separator, Minimum and Maximum read only the digits before the separator, so
1٫9passes a maximum of 1. - Size doesn't count:
1e400passes, though it's too big for the float types most programs use.
Features
- Accepts e notation such as 1e5 and 2.5E-3
- Dot, comma or Arabic decimal separator
- Optional minimum and maximum, both included
- Results as you type, with no button to press
- Runs in your browser, so nothing you type is sent anywhere