ULong Variable not working!

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
User avatar
sysprofessional
Posts: 53
Joined: Sat Oct 26, 2013 7:16 pm
Contact:

ULong Variable not working!

Post by sysprofessional »

Hi everyone,

I'm using FC 6.1.4 with 16f887, facing issue with Ultra Long variable ,it should handle value between (0 to 4294967295) .
But its acting like Long variable ,(-2147483648 to 2147483647), Can someone please resolve this for me ?
any help will be appreciated,

Thanks in advance

kersing
Valued Contributor
Valued Contributor
Posts: 1949
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Contact:

Re: ULong Variable not working!

Post by kersing »

Could you provide some context? May-be even a flowchart demonstrating the issue?
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
sysprofessional
Posts: 53
Joined: Sat Oct 26, 2013 7:16 pm
Contact:

Re: ULong Variable not working!

Post by sysprofessional »

kersing wrote:Could you provide some context? May-be even a flowchart demonstrating the issue?
Hi Kersing,
Simple test Just put a calculation icon in flowchart and calculate the value " test = 2+2147483647 " result overflowing like -2147483647,test variable already added as ULong.
Flowchart image attached.
Untitled-1.jpg
Untitled-1.jpg (97.15 KiB) Viewed 1730 times

mnf
Valued Contributor
Valued Contributor
Posts: 853
Joined: Wed May 31, 2017 11:57 am
Contact:

Re: ULong Variable not working!

Post by mnf »

It could well be that the display routine in FC expects a signed long rather than an unsigned long. The value is probably correct - but is displayed incorrectly...

Martin


User avatar
sysprofessional
Posts: 53
Joined: Sat Oct 26, 2013 7:16 pm
Contact:

Re: ULong Variable not working!

Post by sysprofessional »

Unfortunately same result in simulation,i'm wondering because i have write many programs using ULong,may be one year ago,but this time idk why strange behavior from ULong.I have recently uninstalled FC 6.1.4 and install old version 6.1.0,but no luck ,can it be windows issue?
here is the simulation result ULong incremented by 1 , every second
ULongTest.jpg
ULongTest.jpg (217.79 KiB) Viewed 1721 times

mnf
Valued Contributor
Valued Contributor
Posts: 853
Joined: Wed May 31, 2017 11:57 am
Contact:

Re: ULong Variable not working!

Post by mnf »

Same result - as soon as bit 31 is set - the display routine assumes that it is a negative number. Try converting the number to a hex string then output that....

Martin

User avatar
sysprofessional
Posts: 53
Joined: Sat Oct 26, 2013 7:16 pm
Contact:

Re: ULong Variable not working!

Post by sysprofessional »

I have tested its working fine on hardware, just FC simulating it wrongly,
tested in this way.
1. receiving 32bit string at Comport ,
2. converted it to ULong.
3. splitting into 4 bytes ,
4. stored into EEprom.
5. extract back to 4 bytes, byte0,byte1,.....and so on
i have checked here all 4 values in the EEprom perfect.
6. combining these 4 values to a ULong.

its working fine till here but when i try to convert it to string at step 7 ,again resulting in Long (-2147483648 to 2147483647)

7. String = ToString$(ULong);

any suggestions .....?
how can i convert 32bit Ultra Long to String.

mnf
Valued Contributor
Valued Contributor
Posts: 853
Joined: Wed May 31, 2017 11:57 am
Contact:

Re: ULong Variable not working!

Post by mnf »

You can use NumberToHex$(x) - which returns a string. This works correctly (ie it takes an unsigned long and returns a string)

If you need the value in decimal that is also fairly easy - attached is a very simple demo - that first converts (-1 - so maximum 32 bit number (2^32 - 1)) to a hex number and then converts it to a decimal string....
test.fcfx
(7.72 KiB) Downloaded 53 times
Martin

User avatar
sysprofessional
Posts: 53
Joined: Sat Oct 26, 2013 7:16 pm
Contact:

Re: ULong Variable not working!

Post by sysprofessional »

I have already done using that method. btw thanks for your co-operation .

Best of luck all of you guys.

User avatar
Steve
Matrix Staff
Posts: 3193
Joined: Tue Jan 03, 2006 3:59 pm
Contact:

Re: ULong Variable not working!

Post by Steve »

For info, I checked v8 and it seems to work fine. I assume this bug was fixed a while ago in v7 or v8.
ulong.png
(18.4 KiB) Downloaded 1222 times

Post Reply