Page 1 of 1

Long and ULong variables not working in fc8

Posted: Sat Oct 13, 2018 7:25 am
by kg300
i am using 30 days trail of fc8. test program working in Fc simulation but not working on physical lcd. string printing is working on physical LCD but Long and Ulong calculation not working.

Re: Long and ULong variables not working in fc8

Posted: Sat Oct 13, 2018 9:05 am
by medelec35
Hi,
For displaying long and ulong numbers and maybe uint instead of using PrintNumber you need to use PrintFormattedNumber
If variable is Ulong then use 1 for format
If variable is long then use 0 for format

Re: Long and ULong variables not working in fc8

Posted: Sat Oct 13, 2018 12:36 pm
by kg300
Still not working. but i think this is problem in calculation icon, when i put value directly in long variable, it display fine, but when i put the SUM of two values in this variable it not exceed more then 32000 (like an Int variable). Is flowcode Trail version support morer then Int Variables??

Re: Long and ULong variables not working in fc8

Posted: Sat Oct 13, 2018 12:44 pm
by kersing
For math to use long type you need to assign the first value to the long type and then perform the operation on that long type variable. If you multiply two integers the result will be integer and that will be 'expanded' to long. If you assign the value to a long and then multiply the long with an integer the result will be long. (That is standard C practice, not limited to Flowcode)
Applies to all calculations, not only multiplication but addition, subtraction etc.

Re: Long and ULong variables not working in fc8

Posted: Sat Oct 13, 2018 1:17 pm
by kg300
but the same program working fine with FC5, FC6 & FC7, not in FC8. Calculation not exceed more then 32000
:(

Re: Long and ULong variables not working in fc8

Posted: Sat Oct 13, 2018 1:56 pm
by kersing
Does it work on hardware or in simulation for the other versions?

Re: Long and ULong variables not working in fc8

Posted: Sat Oct 13, 2018 2:27 pm
by medelec35
Hi,
I have to agree with kersing.
BoostC compiler which is all flowcode versions up to and including V6 will work the way you want it to.
All versions V7 or greater will not work unless you do what kersing has suggested since the Ulong is typecast to signed integer.
Can you confirm about v7 working as that uses same compiler as V8.
The way to get it to work could be:
Should work.png
(93.32 KiB) Downloaded 1828 times

Re: Long and ULong variables not working in fc8

Posted: Sat Oct 13, 2018 2:50 pm
by kg300
kersing can u modify it for me.
it working both on hardware and in simulation in fc6.
but in fc8, it simulate ok but not working on hardware. if i do something wrong in fc8 so please modify it for better understand

Re: Long and ULong variables not working in fc8

Posted: Sat Oct 13, 2018 3:11 pm
by kersing
See Martins message above your reply.

Re: Long and ULong variables not working in fc8

Posted: Fri Sep 04, 2020 8:30 pm
by AbhijitR
Hello! KERSING
kersing wrote:
Sat Oct 13, 2018 12:44 pm
For math to use long type you need to assign the first value to the long type and then perform the operation on that long type variable. If you multiply two integers the result will be integer and that will be 'expanded' to long. If you assign the value to a long and then multiply the long with an integer the result will be long. (That is standard C practice, not limited to Flowcode)
Applies to all calculations, not only multiplication but addition, subtraction etc.
Many thanks for the post, it worked for me.

Abhi