Hello,

I did search around and there are few examples about this situation (not much as I would have expected though), but I want to know the procedure or how to find the solution.

Basically I have a 32-bit UNSIGNED register. I want to know how to calculate the value when I subtract 1 when the value is zero (all zero bits).

Any reference to a tutorial about this specific case or explanation is appreciated.

Cheers.

Basically I have a 32-bit UNSIGNED register. I want to know how to calculate the value when I subtract 1 when the value is zero (all zero bits).

So you have 32 bits of 0. Assume for argument's sake there is a 1 in the next bit (bit 33). Subtract 1. What do you get?

That's how you figure it out.

The easy way is to simply know that if you have all 0s, when you subtract 1 you get all 1s. Doesn't matter if the value is signed or unsigned.

Thank you very much WaltP.
So when I subtract 1 from an all zero register it goes to its highest value.

Cheers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.