counting with uLong numbers

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times

counting with uLong numbers

Post by brandonb »

i have a project that i want to count higher numbers than 65535, the next level is ulong which counts over 4 billion numbers, if i count at a 1khz frequency will there be any issues? it seems a bit insane, how many registers does it take to be able to count to 4.2 billion anyway, 4 registers isnt it (256x256x256x256)? .....question two, in program i have a commanded count in a 16 bit uint variable that goes to 65535, i have the screen to show "error" with numbers above 32767, can i command a number with a 16 bit integer using numbers below 65535 but compare the accumulated count using a 32 bit number in the 16 bit range? reason why i need a 32 bit number is because in another menu option i free count numbers, then save the number and data into memory to later recall the data to recreate that menu options tests, this number can go into the 100,000 ranges.... i hope you guys can make sense out of the way its written since the flowchart is too big to post

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: counting with uLong numbers

Post by Benj »

Hello,
if i count at a 1khz frequency will there be any issues?
No I don't see why there would be any as long as your micro is running fast enough to keep up.
4 registers isnt it (256x256x256x256)?
Yep the long variable type consumes 4 bytes in memory.
can i command a number with a 16 bit integer using numbers below 65535 but compare the accumulated count using a 32 bit number in the 16 bit range?
Yes you should be able to shift the long variable so that it falls back within the 16-bit range.

checkvar = longvar >> 16

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times

Re: counting with uLong numbers

Post by brandonb »

thanks ben overlooked a detail, had to use 32 bit for all counting pids, works great at 150k counts with 484hz the freq is uneffected

Post Reply