Class ToonNumbers

java.lang.Object
io.micronaut.serde.toon.util.ToonNumbers

@Internal public final class ToonNumbers extends Object
Formats numbers in the canonical decimal form required by the TOON specification: no leading zeros, no trailing fractional zeros, -0 normalized to 0, NaN/infinite values encoded as null, and scientific notation only outside the 1e-6 <= |n| < 1e21 magnitude window. A BigInteger outside the long range is written as a quoted plain decimal string, so that no precision is lost.
Since:
3.3.0
See Also:
  • Method Details

    • format

      public static String format(Number number)
      Formats the given number in canonical TOON decimal form.
      Parameters:
      number - The number to format
      Returns:
      The canonical decimal (or, outside the plain-form magnitude window, scientific notation) representation, a quoted decimal string for a BigInteger outside the long range, or "null" for a NaN or infinite floating point value