DynamicExpresso icon indicating copy to clipboard operation
DynamicExpresso copied to clipboard

Is this support biginter?

Open caleb20000 opened this issue 3 years ago • 3 comments

Hello: when i " Install-Package DynamicExpresso.Core " in C#(vs2019) , var interpreter = new Interpreter(); var wawawa = interpreter.Eval("335555555555333333333*444444444444444444444444444"); then throw (DynamicExpresso.Exceptions.ParseException:“Invalid integer literal '335555555555333333333' (at index 0).” )

Can you dim variable with biginter?

caleb20000 avatar Nov 02 '21 01:11 caleb20000

I suspect that this

335555555555333333333*444444444444444444444444444

is not a valid C# code and the idea of DynamicExpresso is to follow C# rules.

Can you please check if this is valid with C#?

davideicardi avatar Nov 02 '21 08:11 davideicardi

It's not valid C#: 335555555555333333333 is too large to be represented by a C# integer, and the C# compiler will reject it with error CS1021 Integral constant is too large.

To compile your expression, you must do:

var a = BigInteger.Parse("335555555555333333333");
var b = BigInteger.Parse("444444444444444444444444444");
var c = a * b;

That being said, maybe we can add an option (or reuse the DefaultNumberType option) to automatically parse large integers as big integers?

metoule avatar Nov 02 '21 08:11 metoule

@caleb20000 Is this a real scenario or it was just a test? Do you expect that someone should really input such kind of expressions?

davideicardi avatar Nov 02 '21 08:11 davideicardi