Skip to content

Main content

Mantissa Exponent Field Width Tool

Count literal ASCII numeric-field widths including signs and decimal point, without converting or normalizing the number.

Loading tool…

Description

Parse a signed decimal mantissa with optional e/E signed integer exponent.

Alignment requires a declared measure of width. ASCII token characters, supplied display-cell widths and actual rendered glyph widths are different, so a column budget is meaningful only under its stated convention.

Parse a signed decimal mantissa with optional e/E signed integer exponent.

When to use this tool

Use Mantissa Exponent Field Width when you need a supplied field-width or padding calculation.

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 mantissaWidth, exponentWidth, exponentPresent. Inspect exponentPresent before interpreting the associated values.

Parse a signed decimal mantissa with optional e/E signed integer exponent. Return mantissa text length, exponent-field length excluding e/E, and exponent presence.1

Input fieldMeaning and unitsAccepted input
tokenTokenRequired. Text; maximum UTF-16 length 8192.
Output fieldInterpretationReturned shape
mantissaWidthMantissa WidthRequired. Safe integer.
exponentWidthExponent sign/digit character count excluding e/E; zero if no exponent.Required. Safe integer.
exponentPresentExponent PresentRequired. Boolean.
json
{
  "input": {
    "token": "-1.20e+03"
  },
  "output": {
    "mantissaWidth": 5,
    "exponentWidth": 3,
    "exponentPresent": true
  }
}

Limitations and assumptions

  • Lengths count ASCII token characters including signs and digits; they are not display-cell measurements or numeric precision. No exponent yields width zero.
  • 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

Measure text in the actual font, terminal or output environment when visual alignment matters. Account for encoding, combining marks, wide characters and locale rather than inferring display width from text length alone.

References

  1. Calculation and input contract: format/mantissa-exponent-field-width — tool.io

Similar or alternative tools