Skip to content

Cast error when OptionForceIntegerNumbersEvaluationsAsDoubleByDefault is true #33

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
ghost opened this issue Apr 10, 2019 · 2 comments
Closed
Labels

Comments

@ghost
Copy link

ghost commented Apr 10, 2019

Hi everybody,
I noticed that when OptionForceIntegerNumbersEvaluationsAsDoubleByDefault is turned on, the Round function would throw an Invalid cast exception.

The problem in around line 471, where:
return Math.Round(Convert.ToDouble(self.Evaluate(args[0])), (int)self.Evaluate(args[1]), (MidpointRounding)self.Evaluate(args[2]));

tries to cast to int a (now forced) Double value.

I suggest to substitute the cast with a Convert.ToInt32()

Same thing a few rows down, always with Math.Round() call.

codingseb added a commit that referenced this issue Apr 10, 2019
@codingseb
Copy link
Owner

Hi @mcicognani.
Thanks for this issue.

I made the correction in the dev branch with an other correction of the same kind when declaring an array with new string[2] for example.

It will be available in Version 1.3.7.0

Otherwise double values can be cast back directly in expression like this (int)5 it use the Convert class internally so the cast should works.

@codingseb codingseb added the bug label Apr 10, 2019
@codingseb
Copy link
Owner

Just published v : 1.3.7.0

codingseb pushed a commit that referenced this issue Apr 17, 2019
…aluationsAsDoubleByDefault = true (One more correction when #33)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant