Skip to content

v0.0.48 - Scientific notation

Choose a tag to compare

@TheJaredWilcurt TheJaredWilcurt released this 29 Oct 04:46
· 42 commits to main since this release
531fbc2

Code and release notes by Claude Opus 5.5 Low Thinking:

Shorter numbers in scientific notation

  • Large and small values use scientific notation when it's shorter. Values with a unit or % get the shortest form (1000000px → 1e6px, -0.000001px → -1e-6px). The digits are handled as text, so very large or very small numbers aren't rounded.

  • Unitless <number> values are shortened too:

    • in animation-iteration-count, flex-grow, flex-shrink, tab-size and the opacity properties
    • inside scale(), scale3d(), scaleX/Y/Z(), matrix() and matrix3d()

    For example, flex-grow:1000000 → flex-grow:1e6.

  • Integers are left alone. Values that only accept integers, such as z-index and :nth-child() selectors, never get scientific notation, because it would make them invalid.

  • Media query ratios are shortened: (min-aspect-ratio:1000000/1) → (min-aspect-ratio:1e6/1).

  • Existing scientific notation is cleaned up: the e is lowercased, a + on the exponent is dropped, and trailing zeros move into the exponent (1E3px → 1e3px, 1e+3px → 1e3px, 10e3px → 1e4px).

Better time conversion

  • Times are written in whichever of s and ms is shortest, in either direction.
    • 1000000ms → 1e3s
    • 300000000000000000000000000000ms → 3e26s (this used to come out as 3e+29ms)
    • 0.0001s → .1ms
  • Seconds win a tie, so 1234ms → 1.234s.
  • 0ms still becomes 0s.

Fixes

  • Custom properties keep their number type. --x:100.0 is no longer shortened to 100. If the property is registered with <integer> syntax, that change would turn an invalid value into a valid one.
  • A written + sign is kept. This stops tokens like U+1F170 in unicode-range from being broken when numbers are shortened.