Skip to content

Also accept numeric strings when numbers are needed#202

Merged
PhilippImhof merged 5 commits into
FormulasQuestion:mainfrom
PhilippImhof:fix-sigfig
May 4, 2025
Merged

Also accept numeric strings when numbers are needed#202
PhilippImhof merged 5 commits into
FormulasQuestion:mainfrom
PhilippImhof:fix-sigfig

Conversation

@PhilippImhof

Copy link
Copy Markdown
Collaborator

Fixes #201

PHP typically uses "type juggling" to dynamically convert types according to the context, e. g. "12" / "2" is perfectly acceptable. Even more, the result will be of type int.

This PR changes the evaluator's behaviour to follow PHP's principle and accept numeric strings in all places where numbers are expected.

This has one side-effect: as PHP uses a special string concatenation operator (.) whereas we use + for this purpose, a choice has to be made w.r.t. priority. The decision is that the + operator is basically trying to add things and only falls back to mean concatenation if both arguments are non-numeric strings. If the user really wants to concatenate "1" and "2", they must use the join() function instead.

@coveralls

coveralls commented May 3, 2025

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 14819149286

Details

  • 6 of 6 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 95.944%

Totals Coverage Status
Change from base Build 14747761998: 0.001%
Covered Lines: 4021
Relevant Lines: 4191

💛 - Coveralls

@PhilippImhof PhilippImhof merged commit 445eeb9 into FormulasQuestion:main May 4, 2025
46 checks passed
@PhilippImhof PhilippImhof deleted the fix-sigfig branch May 4, 2025 08:50
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.

Urgent: No backwards compatibility for numerical use of the sigfig function's result

2 participants