-
Notifications
You must be signed in to change notification settings - Fork 123
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
Mixing decimal and double in calculations #40
Comments
I'd also like to know if this is a possibility. This would be handy for my use case. |
Trying to multiply a decimal with a double is not valid C#, so you need a conversion. |
That being given, the intent here is to provide a DSL for expressions. It doesn't have to mirror C# perfectly, so much as accommodate useful cases.
This is the real issue at hand. My use case required maintaining floating point integrity (for financial calculations) and so assuming all constants are Decimal would be exceptionally useful. |
In my use case, I use exclusively decimal calculations, and the some constants are input by the user (formulas are written by the user). So it would be very useful that constants in formulas are assumed to be decimal.
Oscar
El 13 ene. 2019, a la(s) 22:35, Hussein Farran <[email protected]> escribió:
That being given, the intent here is to provide a DSL for expressions. It doesn't have to mirror C# perfectly, so much as accommodate useful cases.
Is there any way to force flee to assume all constants are decimal?
This is the real issue at hand. My use case required maintaining floating point integrity (for financial calculations) and so assuming all constants are Decimal would be exceptionally useful.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Having same Issue - anyone found a solution besides adding an m to every numer with a dot in it? |
+1 for me... for information, financial and accountancy computations can't possibly done in float. These computations must be done with a precise type like decimal. Otherwise, computations can provide unexpected results like 15.000000000000000000001. |
I accomplished this with the Options. Not sure when this was added, but you can default the literals to Decimal using this:
|
hello there, I had the same problem, you can use the following code to force the Flee parser to not do any integer division any more, and of course you would take the results from the parser and convert them to decimals ExpressionContext context = new ExpressionContext(); |
if a decimal variable like
decimal vdec = 10 is used in a formula,
evaluating a formula like "vdec * 1.23"
throws an error : Flee.PublicTypes.ExpressionCompileException: 'ArithmeticElement: Operation 'Multiply' is not defined for types 'Decimal' and 'Double''
I found a workaround changing the formula to "vdec * 1.23M", but this is not very nice...
Is there any way to force flee to assume all constants are decimal?
Note that mixing decimal and int : "vdec * 2" is OK.
The text was updated successfully, but these errors were encountered: