From: jonghwa3.lee@samsung.com
To: Stephen Warren <swarren@wwwdotorg.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>,
Venu Byravarasu <vbyravarasu@nvidia.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"a.zummo@towertech.it" <a.zummo@towertech.it>,
Andrew Morton <akpm@linux-foundation.org>,
"rtc-linux@googlegroups.com" <rtc-linux@googlegroups.com>
Subject: Re: [PATCH] rtc: Modify leap year test for more simpler way
Date: Thu, 07 Feb 2013 10:15:57 +0900 [thread overview]
Message-ID: <5113004D.9050107@samsung.com> (raw)
In-Reply-To: <51129CC2.7040709@wwwdotorg.org>
On 2013년 02월 07일 03:11, Stephen Warren wrote:
> On 02/06/2013 06:00 AM, Haojian Zhuang wrote:
>> On Wed, Feb 6, 2013 at 8:43 PM, <jonghwa3.lee@samsung.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.
>
Sorry, I was wrong. I didn't know the definition of leap year not including
multiple of 4. Sorry for making noise.
Thanks,
Jonghwa
> http://en.wikipedia.org/wiki/Leap_year#Algorithm
>
prev parent reply other threads:[~2013-02-07 1:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-06 11:22 [PATCH] rtc: Modify leap year test for more simpler way Jonghwa Lee
2013-02-06 11:42 ` Venu Byravarasu
2013-02-06 12:43 ` jonghwa3.lee
2013-02-06 12:53 ` jonghwa3.lee
2013-02-06 13:00 ` Haojian Zhuang
2013-02-06 18:11 ` Stephen Warren
2013-02-07 1:15 ` jonghwa3.lee [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5113004D.9050107@samsung.com \
--to=jonghwa3.lee@samsung.com \
--cc=a.zummo@towertech.it \
--cc=akpm@linux-foundation.org \
--cc=haojian.zhuang@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rtc-linux@googlegroups.com \
--cc=swarren@wwwdotorg.org \
--cc=vbyravarasu@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox