Repository navigation
Calculator: constants, molar mass, text functions, bracketed phrases and a faster engine - #1928
Open
list-jonas wants to merge 8 commits into
Open
list-jonas wants to merge 8 commits into
list-jonas wants to merge 8 commits into
Conversation
…re units - `12 % 5` is a remainder when a plain number follows the `%` - `today - 1.1.2026 + 3`, `week 44 2026` - `1.75 as improper` / `as mixed`, `15% decrease from 813` - `speed of light in km/s`, `molar mass of C6H12O6`, `5:00 min/km in km/h` - `first 10 characters of "hello"` and other quoted-text functions - About 35 new units (eV, ångström, therm, mach, decade, grain, …)
… paths - ASCII fast paths for whitespace and digit checks in the tokenizer and word splits - Echo the expression in one pass instead of split + two Foundation replaces - Parse short integers arithmetically instead of through a String - Skip the time-zone grammar for queries with no letters or clock
…alf-typed 'of' as a formula
|
Thanks for the PR! A maintainer will review it soon. |
list-jonas
marked this pull request as ready for review
November 15, 2026 22:15
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue
Closes #754
Closes #85 (the
%spelling:10 % 3,17 % 5,2 + 10 % 3;modalready worked)What changed
New calculator inputs:
today - 1.1.2026 + 3,week 44 202612 % 5(remainder when a plain number follows%),1.75 as improper/as mixed15% decrease from 813(andincrease)speed of light in km/sand ~20 other constants,molar mass of C6H12O65:00 min/km in km/h,4° in nautical miles, ~35 new units (eV, ångström, therm, mach, decade, grain, …)first 10 characters of "hello",length of "…","…" in uppercase(15% tip on $80) / 2,(today - 1.1.2026) / 2,(c4 to hz) * 2.(2m)shows2 m. The card dims brackets like operators.New code lives in
CalcScienceandCalcText. A one-pass scan for a trigger word (or a quote mark) lets other queries skip them.The calculator is also faster:
Memory footprint
Leak-tested:
Demo
Drawbacks
10 percent 3and5% 2now give a remainder, because the tokenizer can't tellpercentor5%from%. Percentages still work as before:10% of 89is 8.9,89 + 10%is 97.9 and10% off 89is 80.1.(today - 1.1.2026) / 2takes ~80 µs.Tests & validation
./Scripts/run-tests.sh CalcTestspasses, with new cases for each feature and for the edge cases../Scripts/lint.shis clean and the Debug build has 0 new warnings.mainlost no answers. Every change is a new answer, or an error card on fuzz garbage that now shows nothing.CalcPerformanceTestsplus a keystroke-by-keystroke typing test.