Skip to content

Main content

JSON Number Scale Token Tool

Inspect the exact decimal scale of a valid JSON number token without rounding through Number.

Loading tool…

Description

Validate a JSON number token, count fractional digits, parse its optional signed exponent as a safe integer, and return decimalScale = fractionDigits - exponent.

A JSON number's grammar, decimal spelling, and parsed binary value are different layers. Exponents, leading zeros, and negative zero can carry lexical information lost during numeric conversion.

Validate a JSON number token, count fractional digits, parse its optional signed exponent as a safe integer, and return decimalScale = fractionDigits - exponent.

When to use this tool

Use JSON Number Scale Token when you need a numeric token's spelling or serialization convention.

How to use the tool and how it works

  1. Enter token. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read fractionDigits, exponent, decimalScale. Use the output convention below.

Validate a JSON number token, count fractional digits, parse its optional signed exponent as a safe integer, and return decimalScale = fractionDigits - exponent.1

Input fieldMeaning and unitsAccepted input
tokenTokenRequired. Text; maximum UTF-16 length 8192.
Output fieldInterpretationReturned shape
fractionDigitsFraction DigitsRequired. Safe integer.
exponentExponentRequired. Safe integer.
decimalScaleFractional digit count minus exponent; lexical decimal scale rather than a precision estimate.Required. Safe integer.
json
{
  "input": {
    "token": "1.230e2"
  },
  "output": {
    "fractionDigits": 3,
    "exponent": 2,
    "decimalScale": 1
  }
}

Limitations and assumptions

  • The coefficient is not evaluated; leading fractional zeros are counted and scale is not a precision or significant-digit estimate.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.

Alternative or Complementary methods

Use an exact decimal parser when preserving large integers, decimal scale, or lexical round trips is required.

References

  1. Calculation and input contract: json/json-number-scale-token — tool.io

Similar or alternative tools