Page 1 of 1

Urgent Variable overflow in calculation

Posted: Wed Dec 06, 2023 4:19 pm
by lucibel
Hi,
I need help to solve this problem ASAP
it seems that there is overflow of the variable when make this calculation
51569*2=37602 instead of 103138
I think it's overflow because 103138-65536=37602
But the calculation result is store in ULong variable
Test Flowcode1.fcfx
(14.32 KiB) Downloaded 153 times
May be I did something wrong !
Thx for your prompt help

Re: Urgent Variable overflow in calculation

Posted: Wed Dec 06, 2023 4:42 pm
by Steve-Matrix
What if you do the following in a calculation icon?

Code: Select all

Max_Flow_Time = Max_Flow_Const
Max_Flow_Time = Max_Flow_Var * Max_Flow_Time
Or alternatively, you could try making the Max_Flow_Var also ULONG instead of a BYTE.

Both of these should force the compiler to perform the calculation without truncating to a UINT.

Re: Urgent Variable overflow in calculation

Posted: Wed Dec 06, 2023 5:04 pm
by lucibel
this work

Code: Select all

Max_Flow_Time = Max_Flow_Const
Max_Flow_Time = Max_Flow_Var * Max_Flow_Time
thx

Re: Urgent Variable overflow in calculation

Posted: Wed Dec 06, 2023 5:05 pm
by lucibel
Max_Flow_Var also ULONG instead of a BYTE also not working