Re: C question about bitmasks in datetime.c

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: C question about bitmasks in datetime.c
Date: 2013-10-01 15:24:41
Message-ID: 20131001152441.GD13385@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2013-10-01 15:31:41 Re: Documentation for SET var_name FROM CURRENT
Previous Message Andres Freund 2013-10-01 15:17:35 Re: C question about bitmasks in datetime.c