-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for units on nummerial values #122
Comments
This would be a bit more complicated. First, it would require integers and floats to be types other than I am happy to accept pull requests that push this issue forward. |
@ISibboI Like, 2km+1m = 2100m. Or what about having result be string which multiplies units and leaves as it is for add expression. |
I think this should be done in a type-safe way, meaning that the evalexpr should know about units somehow. But only in the case where the user actually wants to use units. The way to go would be to make int and float types generic, and then allow the user to supply their own types with their own parsing mechanisms, operations, etc. I have tried making the int and float types generic on branch My current conclusion on that is that the Design-wise, that type should be specified by the context. And it probably requires some rethinking of builtin functions, to e.g. not enforce any numeric type to implement all the trigonometric functions. |
I would like to add units like
px
,rem
,em
, and%
. This should be an opt in feature some how. Most likely a separate function/api. I would like to be able to only allow a set of units I define and error on any unknown units. This would also be useful for people who would like to define units likekm
,ms
, etc.I believe the output should be an expression so it can handle mixing units. For example,
(4px * 8) + 50%
should be32px + 50%
. There doesn't seem to be a type to express this type of output.Node
seems close but it's fields are private.Also unit conversions would be nice but that could be a separate issue.
Edge case:
100% / 3 - 2 * 1em - 2 * 1px
I believe this would be33.333...% - 2em - 2px
The text was updated successfully, but these errors were encountered: