Re: C question about bitmasks in datetime.c - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: C question about bitmasks in datetime.c
Date
Msg-id 20131001152441.GD13385@momjian.us
Whole thread Raw
In response to Re: C question about bitmasks in datetime.c  (Andres Freund <andres@2ndquadrant.com>)
List pgsql-hackers
On Tue, Oct  1, 2013 at 05:17:35PM +0200, Andres Freund wrote:
> On 2013-10-01 11:15:36 -0400, Bruce Momjian wrote:
> > I see a few cases of this code in src/backend/utils/adt/datetime.c:
> > 
> >     else if ((fmask & DTK_DATE_M) != DTK_DATE_M)
> > 
> > Wouldn't this be clearer as:
> > 
> >     else if (fmask & DTK_DATE_M)
> 
> That doesn't have the same meaning. The latter is trueif only one bit of
> DTK_DATE_M is set, while the former requires all bits to be set.

Oh, I see it now --- DTK_DATE_M is not a bit but rather a set of bits,
and they are testing if _all_ are set.  Thank you!

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: C question about bitmasks in datetime.c
Next
From: Alvaro Herrera
Date:
Subject: Re: Documentation for SET var_name FROM CURRENT