Skip to content

Conversation

@Mc-Zen
Copy link
Owner

@Mc-Zen Mc-Zen commented Oct 27, 2025

This PR introduce a settable parameter num.exponent that can be set to

  • auto (default behaviour, displays the explicitly given exponent),
  • "sci" (employ scientific notation), or (sci: n) to activate scientific notation only when the absolute of the exponent is at least n or (sci: (min, max)) to activate scientific notation only when the exponent is less or equal to min or greater or equal to max
  • "eng" (employ engineering notation),
  • (fixed: n) to fix the exponent.

The latter three options are regardless of the input exponent, the number is just updated accordingly and the input exponent is taken into account.

Moreover, a new parameter prefix: auto | none has been added to the unit settings. It can be set through set-unit(prefix) or when calling a unit zi.m(prefix: auto)[2km]. When the prefix is set to auto and num.exponent is set to "eng" an automatic prefix will be added to the unit, replacing the exponent. This feature is by default activated.

#set-num(exponent: "eng")

#zi.s[1e-7] // will produce "100ns"

Closes #17, closes #28.

Copy link

@amesgen amesgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sci does exactly what I wanted, thanks a lot!

@Mc-Zen Mc-Zen merged commit afa1e63 into main Oct 28, 2025
1 check passed
@Mc-Zen Mc-Zen deleted the exponent-modes branch October 28, 2025 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatic exponent formatting? feature: support engineering notation

3 participants