Skip to content

Main content

JSON: JSON Number Negative Zero Lexeme Tool

Recognize exact lexical negative zero in a strict JSON number without confusing underflowing nonzero coefficients with zero.

Loading tool…

Description

Validate JSON number grammar.

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 JSON number grammar.

When to use this tool

Use JSON: JSON Number Negative Zero Lexeme when you need a numeric token's spelling or serialization convention.

How to use the tool and how it works

  1. Enter lexeme. 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 result. Expand result to inspect the returned fields.

Validate JSON number grammar. Inspect the coefficient before any exponent for nonzero digits, returning negativeSign and negativeZero when a minus sign prefixes an all-zero coefficient.1

Input fieldMeaning and unitsAccepted input
lexemeSupplied token spelling; it is not automatically decoded text.Required. Text. Implementation limit: 8192 Unicode code points and 16384 UTF-16 code units.
Output fieldInterpretationReturned shape
resultResultRequired. Object.
result.negativeZeroNegative ZeroCalculated result member: boolean.
result.negativeSignNegative SignCalculated result member: boolean.
json
{
  "input": {
    "lexeme": "-0.00e+12"
  },
  "output": {
    "result": {
      "negativeZero": true,
      "negativeSign": true
    }
  }
}

Limitations and assumptions

  • A tiny nonzero coefficient that underflows numerically is not classified as lexical negative zero; no Number conversion is used.
  • Outputs are nested inside result. 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-negative-zero-lexeme — tool.io

Similar or alternative tools