counting with uLong numbers
Moderator: Benj
-
- Posts: 438
- Joined: Mon Aug 29, 2011 12:26 am
- Location: arizona
- Has thanked: 175 times
- Been thanked: 173 times
counting with uLong numbers
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
- 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
Hello,
checkvar = longvar >> 16
No I don't see why there would be any as long as your micro is running fast enough to keep up.if i count at a 1khz frequency will there be any issues?
Yep the long variable type consumes 4 bytes in memory.4 registers isnt it (256x256x256x256)?
Yes you should be able to shift the long variable so that it falls back within the 16-bit range.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?
checkvar = longvar >> 16
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel