lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <51129CC2.7040709@wwwdotorg.org>
Date:	Wed, 06 Feb 2013 11:11:14 -0700
From:	Stephen Warren <swarren@...dotorg.org>
To:	Haojian Zhuang <haojian.zhuang@...il.com>
CC:	jonghwa3.lee@...sung.com, Venu Byravarasu <vbyravarasu@...dia.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"a.zummo@...ertech.it" <a.zummo@...ertech.it>,
	Andrew Morton <akpm@...ux-foundation.org>,
	"rtc-linux@...glegroups.com" <rtc-linux@...glegroups.com>
Subject: Re: [PATCH] rtc: Modify leap year test for more simpler way

On 02/06/2013 06:00 AM, Haojian Zhuang wrote:
> On Wed, Feb 6, 2013 at 8:43 PM,  <jonghwa3.lee@...sung.com> wrote:
>> On 2013년 02월 06일 20:42, Venu Byravarasu wrote:
>>> By definition, leap year is one, which is a divisible by 4 & 400, excluding multiples of 100s.
>>> Hence I feel this patch is not correct.
>>
>> No, I think you might misunderstood the it's meaning. The former code checks
>> whether if it is multiple of 4 or not. Formal mathematical way to verify multiple of 4
>> is just checks the last two digits are multiple of 4. This '(!year % 4) && (year % 100)'
>> part does it. But with only that checking, it may miss the case of multiple of 400 which
>> is also multiple of 4. Then my modification checks in hexadecimal, whether if number
>> has any of 1st and 2nd bit with value 1. Because any number which has all bits above
>> the 3rd can be divided with 4(2^2).
>> (e.g. 44(0b101100) = 2^5+2^3+2^2 = 2^2(2^3 + 2 + 1))
>> So It does same things with less instructions.
> 
> I still can't understand your logic.
> 
> Please check whether 200 year is leap year.
> 
> 200(decimal) = 2b11001000
> 
> !(200 & 0x3) = 1 (Your condition said that 200 year is a leap year.)
> 
> According to this logic in below.
>  if year mod 4 = 0 and year mod 100 <> 0 or year mod 400 = 0, then
> it's a leap year.
> 
> This tells us that 200 year isn't a leap year because 200 mod 100 ==
> 0. So who is wrong?

The rule is: it's a leap year if divisible by 4, unless it's divisible
by 100, but actually also including years divisible by 400. So, the
current code is correct, and the patch is wrong.

http://en.wikipedia.org/wiki/Leap_year#Algorithm
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ