Skip to content
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

Intelligente type casting #137

Open
Alisis33 opened this issue May 30, 2022 · 0 comments
Open

Intelligente type casting #137

Alisis33 opened this issue May 30, 2022 · 0 comments

Comments

@Alisis33
Copy link

The handling of numbers types could be more tollerant/intelligente. Not only casting to double. This could be used for easy and simple formulas, without the neet of a exact type casting.

For example it could cast automatically to the type given in the generics. And it could detect floating point and integer types. And the parser could detect as good as possible what type is needed.

Like for example

evaluator.Evaluate<double>("123 + (255 << 4) + -0b11 * 0.5")

Automatically to

evaluator.Evaluate<double>("(double)(  (double)123 + ((ulong)255 << (int)4) + (long)-0b11 * (double)0.5  )")

or

evaluator.Evaluate<int>("123 + (0xff << 4) + -0b11 * 0.5")

Automatically to

evaluator.Evaluate<int>("(int)(  (ulong)123 + ((ulong)0xff << (int)4) + (long)-0b11 * (double)0.5  )")

? Maybe even this, by simply use the integer part? With the hope that the user know what he is doing.
123 & 2.5
Or
125.5 << 2.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants