Calculator number input

Calculator Locale Number Input Test Matrix

A strict locale-aware parsing contract and sixteen executed cases for decimal marks, grouping, scale, ranges and recoverable calculator errors.

Direct answer

Do not parse calculator numbers by deleting commas and periods. Choose one accepted locale, derive its decimal and grouping tokens, validate the complete string and grouping pattern, enforce sign, scale and range rules, then normalize exactly once. Preserve the user's original entry for an accessible correction path; treat ambiguous and mixed conventions as errors rather than guesses.

Definition

Locale-aware numeric input is the process of accepting, validating and normalizing a number under one declared locale and numeric policy. Formatting and parsing are different operations: a formatter can expose a locale's tokens, but an application still needs an explicit parser, scale, range and error-recovery contract.

Key findings

Verified 21 October 2026

  • The same visible punctuation can represent different values: 1,234.56 is valid under the published en-US contract, while 1.234,56 is valid under de-DE and rejected under en-US.
  • Intl.NumberFormat and formatToParts identify locale-specific output tokens, but they do not replace an application's parsing and validation policy.
  • Grouping must be validated before punctuation is removed; otherwise 12,34.56 can be silently transformed into an unintended number.
  • The reference parser preserves the original string for recovery and stores a separate normalized machine value only after the complete string, scale and range pass.

What must a locale-aware number contract define?

A locale name alone is not enough. Publish the field's number type and every decision that can change acceptance or the stored value. Version the contract with the formula so later CRM records, calculations and corrections can be replayed.

LOCALE-NUMBER-INPUT-MATRIX

Locale-aware calculator input contract
RulePublished referenceWhy it matters
Localeen-US, de-DE or fr-FR per fieldSelects decimal and grouping tokens
DigitsASCII 0–9Non-Latin digits need a separate documented path
GroupingOptional; exact groups of threePrevents punctuation deletion from hiding bad grouping
SignMinus allowed; plus and parentheses rejectedAvoids undocumented accounting or sign conventions
ExponentRejectedKeeps ordinary calculator fields distinct from scientific input
ScaleAt most two fractional digitsSeparates validation from an explicit rounding policy
RangeField-specific minimum and maximumStops valid syntax from becoming an invalid business value
RecoveryPreserve original stringLets the user correct exactly what they entered

Why are formatting and parsing different?

Intl.NumberFormat formats a numeric value for a locale, and formatToParts exposes output components such as integer, group, decimal and fraction. Those parts are useful for deriving tokens and constructing examples. They do not define which arbitrary input strings an application should accept.

The HTML number control stores a valid floating-point representation even when a browser localizes its interface. The standard also notes that a text control with inputmode can be more appropriate when the spinbox interface is not suitable. Whichever control is used, the server still needs the same input contract as the client.

What did the sixteen locale-input tests cover?

All sixteen cases ran against the published strict reference parser on 21 October 2026. A rejection is an intentional state with a specific correction path, not a failed attempt to guess the user's meaning.

Sixteen executed locale-number fixtures
IDLocale and entryExpected decision
N01en-US · 1,234.56Accept 1234.56
N02de-DE · 1.234,56Accept 1234.56
N03fr-FR · 1 234,56Accept 1234.56
N04en-US · 1.234,56Reject mixed convention
N05de-DE · 1,234.56Reject mixed convention
N06en-US · 12,34.56Reject bad grouping
N07de-DE · 12.34,56Reject bad grouping
N08en-US · 1234Accept 1234
N09en-US · +1234Reject disallowed plus
N10en-US · (1,234.56)Reject unsupported parentheses
N11Empty required fieldRequired error
N12NaN or Infinity textReject non-finite text
N13en-US · 1e3Reject disabled exponent
N14en-US · 1.234Reject scale over two
N15−1 with minimum 0Range error
N161001 with maximum 1000Range error

Worked example: de-DE 1.234,56

Under the published de-DE contract, period is the grouping token and comma is the decimal token. First validate that 1.234,56 has a one-to-three digit leading group, one three-digit group and no more than two fractional digits. Then remove the permitted period, replace the permitted comma with a period and convert the normalized string 1234.56 to a finite numeric value.

Under en-US, the same original string is invalid. The reference does not silently convert it to 1.23456 or 123456. The original string remains available in the field, while the normalized value is stored only after validation succeeds.

How should calculator errors recover accessibly?

Put the expected format in a visible label or nearby instruction, using an example appropriate to the selected locale. When validation fails, identify the field and the accepted format in text, associate the message programmatically with the field and preserve the original value. Do not rely on placeholder text or color alone.

W3C notes that client-side validation can be bypassed and server-side validation is still necessary. Apply the same locale, scale and range contract on both sides; a browser-valid control is not evidence that the downstream calculator, CRM or email received the intended number.

Locale-number release checklist

Ship the field only when display, client parsing, server parsing, calculation and downstream storage agree.

  • Declare one accepted locale or make locale selection explicit.
  • Derive and test the exact Unicode decimal and grouping tokens.
  • Validate grouping before removing separators.
  • Define sign, exponent, whitespace, scale and range rules.
  • Keep formatting separate from parsing and calculation precision.
  • Preserve the original entry through every recoverable error.
  • Use visible format instructions and programmatic error associations.
  • Repeat validation on the server before calculation or delivery.

Verification and correction path

The three primary guidance sources and all sixteen deterministic fixtures were checked on 21 October 2026. A correction report should include the locale, exact Unicode code points, original entry, intended numeric value, field type, scale and range, browser or client, and parser version.

Method and evidence

Evidence type: Versioned locale-input contract, worked normalization example and sixteen executed deterministic parsing-decision fixtures

  1. Declared the accepted locale, decimal token, grouping token, sign rule, grouping rule, scale and range before transforming an input string.
  2. Validated the complete original string before removing one permitted grouping token and replacing one permitted decimal token; ambiguous or mixed conventions were rejected instead of guessed.
  3. Executed sixteen deterministic fixtures across en-US, de-DE and fr-FR inputs, invalid grouping, signs, empty and non-finite values, exponent notation, scale and range boundaries.
  4. Rechecked the HTML Living Standard, MDN's Intl.NumberFormat formatToParts reference and W3C form-validation guidance on 21 October 2026.

Topic score: 4.63 / 5. Business fit 4.8, verified demand 4.5, distinct intent 4.7, original evidence 4.8, citation usefulness 4.5, feasibility 4.3.

Primary sources

Limitations

  • This reference covers three locale contracts with Latin digits; it does not certify every locale, numbering system, browser keyboard, assistive technology or currency convention.
  • Spelled-out numbers, compact notation, scientific notation, accounting parentheses, bidirectional text and non-Latin digits are outside the executed fixtures.
  • The parser rejects fractional scale over two instead of rounding it; products that round must publish and test a separate rounding policy.
  • No named calculator builder, browser matrix, mobile keyboard, assistive technology or production user dataset was tested.
  • The examples validate parsing decisions, not conversion-rate, completion-rate or revenue outcomes.

Verification and corrections

HTML number-input behavior, Intl.NumberFormat token behavior, W3C form-validation guidance and sixteen deterministic parsing fixtures verified 21 October 2026.

Recommended retest: Recheck after any locale, numbering-system, input-control, parser, scale, range, browser-support or error-recovery change.

Found an error or a changed standard? Use the correction process and include the page URL and primary evidence.

Next step

Apply the evidence to your next release

Use the published method, keep a dated test record and revisit the result after the calculator or its operating rules change.

Open the testing protocol