Page 1 of 1

Remainders

Posted: 24 Aug 2010 06:33
by batchfileman
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.

Re: Remainders

Posted: 24 Aug 2010 08:17
by orange_batch

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

Re: Remainders

Posted: 24 Aug 2010 09:22
by ghostmachine4
are you working on MSDOS ? if not, try using vbscript for dates.