-
-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Labels
Preview-FeedbackFeedback gathered during the technical previewFeedback gathered during the technical previewfunctionsIssue pertains to the default function setIssue pertains to the default function set
Milestone
Description
As far as I can tell, in registry.md, the :math
function allows for arbitrary addition and subtraction.
I think this is a problem: it can run into the floating-point math problems well known to most programmers, such as 0.1 + 0.2 != 0.3. For example, a message of the following form does not have well-defined behavior:
.input {$num :number}
.local $num_adjusted = {$num :math subtract=0.1}
.match $num_adjusted
0.1 {{...}}
0.2 {{...}}
0.3 {{...}}
* {{...}}
Are there any use cases for this function other than adding or subtracting integers?
I suggest changing the function to restrict the domain to integers and defining that the math operates as if on decimal values. So, for example, {1.234 :math subtract=1}
should be guaranteed to return 0.234
.
Metadata
Metadata
Assignees
Labels
Preview-FeedbackFeedback gathered during the technical previewFeedback gathered during the technical previewfunctionsIssue pertains to the default function setIssue pertains to the default function set