DynamicExpresso icon indicating copy to clipboard operation
DynamicExpresso copied to clipboard

Basic operations (+, -, *, /) between uint64 and int32 not working

Open mocakturk opened this issue 2 years ago • 3 comments

Hello,

When I execute following expression, I have exception with message: "Invalid Operation". "10ul + 20" (default numeric type is int32)

Normally, uint64 and int32 types should work together. The result should be 30ul in normal conditions.

mocakturk avatar Aug 18 '22 11:08 mocakturk

This is an interesting scenario where the compiler gives results that seem conflicting to me.

var result = 10ul + 5; works exactly as stated in original comment.

However,

var l = 10ul;
var r = 5;
var result = l + r;

results in a compiler error saying the 'Operator "+" is ambiguous on operators of type 'ulong' and 'int''

Anybody have any insight on that?

holdenmai avatar Aug 21 '22 01:08 holdenmai

This is actually quite strange. I suppose that in the first case the compiler is able to infer the type based on the previous number, probably this is some kind of compiler optimization where at the end only 15ul is generated.

What is your use case? Why you need to work with ul numbers? Just to understand if there can be alternatives ...

davideicardi avatar Aug 24 '22 12:08 davideicardi

There are some custom functions I've included: CustomFuncReturnsUint64() + CustomFuncReturnsInt32()

User is able to freely type a formula in my application. This is a possible case.

mocakturk avatar Aug 24 '22 16:08 mocakturk