-
Notifications
You must be signed in to change notification settings - Fork 512
Closed
Labels
Description
Description
The math expression parser in src/lib/litegraph/src/utils/mathParser.ts can produce -0 from expressions like -0, 0 * -1, or 0 / -1. While -0 === 0 is true in JavaScript, the expr-eval library explicitly normalizes negative zero to positive zero (nstack[0] === 0 ? 0 : result) because -0 has caused real issues downstream in some contexts.
Suggested Change
Add normalization at the end of evaluateMathExpression:
return result === 0 ? 0 : resultContext
- Originated from PR [fix] Replace eval() with safe math expression parser #9263 which replaced
eval()with the custom math parser - Comment discussion: [fix] Replace eval() with safe math expression parser #9263 (comment)
- Suggestion by @christian-byrne
- Non-blocking improvement for future PR
References
- PR: [fix] Replace eval() with safe math expression parser #9263
- File:
src/lib/litegraph/src/utils/mathParser.ts
┆Issue is synchronized with this Notion page by Unito
Reactions are currently unavailable