Skip to content

Fix calc.inf, -calc.inf, and calc.nan reprs and displays#4724

Merged
laurmaedje merged 4 commits intotypst:mainfrom
MDLC01:infinite-with-unit-fix
Aug 11, 2024
Merged

Fix calc.inf, -calc.inf, and calc.nan reprs and displays#4724
laurmaedje merged 4 commits intotypst:mainfrom
MDLC01:infinite-with-unit-fix

Conversation

@MDLC01
Copy link
Collaborator

@MDLC01 MDLC01 commented Aug 10, 2024

Fixes #2955.

I decided to use calc.inf and calc.nan instead of float("inf") and float("nan") because the former feel like constants, while the latter feel like more arbitrary ways of getting the values. Ideally, I think float.inf and float.nan would be better (see side note below).

Value Repr Display / str
calc.inf "calc.inf"
-calc.inf "-calc.inf" −∞
calc.nan "calc.nan" NaN
calc.inf * 1pt "calc.inf * 1pt"
-calc.inf * 1pt "-calc.inf * 1pt"

I also added some unrelated float-related tests in the last commit.

As a side note, I'm wondering whether we should move calc.inf and calc.nan to float.inf and float.nan as they seem more related to the IEEE-754 format than to calculations.

@laurmaedje laurmaedje added this pull request to the merge queue Aug 11, 2024
@laurmaedje
Copy link
Member

Thanks!

As a side note, I'm wondering whether we should move calc.inf and calc.nan to float.inf and float.nan as they seem more related to the IEEE-754 format than to calculations.

That makes sense. calc.nan does not seem to be used in Typst Universe. calc.inf is used in three packages. So the breakage is rather minimal. But we could still duplicate them & deprecate the old ones for now. (No infrastructure for deprecating consts though atm.)

Merged via the queue into typst:main with commit 79fb2c3 Aug 11, 2024
@MDLC01 MDLC01 deleted the infinite-with-unit-fix branch August 11, 2024 22:19
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.

Infinite united values are represented weirdly (e.g., infpt)

2 participants