Remainders

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
batchfileman
Posts: 16
Joined: 07 Jun 2010 10:27

Remainders

#1 Post by batchfileman » 24 Aug 2010 06:33

Does batch have a way to deal with remainders?

I am making a calendar in batch that will account for leap years. I want to take the date and divide it by 4. If it has a remainder then it is not a leap year, if it does not then it is a leap year. I cannot find any way to draw out the remainder.

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: Remainders

#2 Post by orange_batch » 24 Aug 2010 08:17

Code: Select all

set /a remainder=%date%%%4,date/=4
if %remainder% NEQ 0 echo:Remainder not equal to 0.


%%4 = %4 = modulus 4

and...

set /a remainder=%date%%%4,date/=4

is the same as:
set /a remainder=%date%%%4
set /a date=%date%/4

ghostmachine4
Posts: 319
Joined: 12 May 2006 01:13

Re: Remainders

#3 Post by ghostmachine4 » 24 Aug 2010 09:22

are you working on MSDOS ? if not, try using vbscript for dates.

Post Reply