number %% 100

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
miskox
Posts: 668
Joined: 28 Jun 2010 03:46

number %% 100

#1 Post by miskox » 26 Feb 2015 15:43

This has been asked in the past (also by myself) but I would like to have this information in one place for all the different operations:

I would like someone to explain these operations we see in some programs:

Code: Select all

set /a remain=cnt %% 100


I tried with a loop to see what happens and I see that the code above calculates the remainder.

Code above is the same as:

Code: Select all

set /a aa=cnt / 100
set /a remain=cnt - aa * 100


Please help and then we can post them all in one post. I think I remember someone saying that these operations are from 'C'?

Thanks.
Saso

ShadowThief
Expert
Posts: 1167
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: number %% 100

#2 Post by ShadowThief » 26 Feb 2015 15:47

You just explained the modulus operator perfectly. What's your question?

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: number %% 100

#3 Post by Squashman » 26 Feb 2015 16:31


miskox
Posts: 668
Joined: 28 Jun 2010 03:46

Re: number %% 100

#4 Post by miskox » 03 Mar 2015 12:44

ShadowThief wrote:You just explained the modulus operator perfectly. What's your question?


I wanted to know what are all possible operators (with the explanation). And I see Squashman provided very useful link.

Thanks.
Saso

Post Reply