Variable Roll Over
SailerMan
Posts: 337
What is the most efficient way to calculate a byte variable rolling over....
What I mean is... Let's say I have a byte Variable...
I increment it by one and the Value goes from 0 to 1 the difference is +1. The if I decrement by 2. I want to get -1, not 255. How can I make this happen without a bunch of If then statements??
·
What I mean is... Let's say I have a byte Variable...
I increment it by one and the Value goes from 0 to 1 the difference is +1. The if I decrement by 2. I want to get -1, not 255. How can I make this happen without a bunch of If then statements??
·
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
In assembler the N flag would be set on a decrement from 0 to 255 so branching can be done without an extra compare or if then type statement.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think outside the BOX!