What is a decimal number?

A decimal number is a number written with a decimal separator between the whole part and the fraction, such as 3.75, -0.5 or 12.00. Prices, weights, grades and percentages are mostly written this way. Many systems also fix how many digits follow the separator: prices in most currencies have two, and a database column of the type DECIMAL(10,2) keeps exactly two.

You check one when a form asks for an amount or a price, or before you import numbers into a database.

Tool description

Type or paste a value into the Decimal number field, and the result shows as you type: "Decimal number is valid" or "Decimal 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 decimals and Maximum decimals set how many digits may follow the separator: the minimum starts on 1, and the maximum starts empty, for no limit. Require a decimal part starts off, so whole numbers such as 42 pass. Turn it on, and whole numbers fail.

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, -7, 3.75, +2.0, 007.50
  • A separator with nothing before it: .5

Numbers that fail

  • A separator with nothing after it: 5.
  • E notation and words: 1e5, Infinity
  • Thousands separators and spaces inside: 1,000.50, 1 000
  • Arabic-Indic digits, even with the Arabic decimal separator

How the decimals settings work

  • They count the digits after the separator, and only when there is one. With both on 2, 9.99 passes and 9.9 and 9.999 fail, but 9 still passes until Require a decimal part is on.
  • Minimum decimals 0 lets a separator end the number, as in 5.. A lone . or -. then passes too.
  • Both take whole numbers, and the maximum can't be lower than the minimum. Anything else, such as a maximum of 0 next to a minimum of 1, gets a message asking you to change them instead of an answer.
  • Minimum decimals can't be empty: while it is, the result asks you to fill it in.

Good to know

  • At its starting settings, this check accepts exactly the same numbers as the Numeric String Validator. The decimals settings are what it adds.
  • Unlike the Float Validator, it never accepts e notation, and it has no range setting: -0.5 passes even where only positive amounts make sense.

Features

  • Checks decimal numbers with or without a sign
  • Limits for the number of decimals
  • Dot, comma or Arabic decimal separator
  • Results as you type, with no button to press
  • Runs in your browser, so nothing you type is sent anywhere