Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, pgsql-committers <pgsql-committers(at)postgresql(dot)org>
Subject: Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign
Date: 2015-04-30 13:21:05
Message-ID: 20150430132105.GA24214@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On Thu, Apr 30, 2015 at 09:07:45AM -0400, Robert Haas wrote:
> >> > > Since abs() is declared to return just an int. I don't see it anywhere
> >> > > in our tree and I'm not sure how portable it actually is, but labs() is
> >> > > supposedly in C89, so perhaps that should be used here instead?
> >> >
> >> > I just removed the "l" for now, since %02d is used to print the result
> >> > of abs() elsewhere. If that isn't right, someone can re-fix my fix.
> >>
> >> Works for me. I'm no longer seeing the warning.
> >
> > Oh, I see now that my commit generated a conflict and didn't apply.
> > Should we try labs() or just ignore it?
>
> If the result is guaranteed to fit in an integer, then there's no
> reason to adopt labs. If you think there are platforms where it would
> overflow int but fit into long, then there might be a reason to change
> it. All things being equal, it'd be nicer if we didn't need to use
> labs(), because every function we depend on is another thing that can
> break on some obscure platform.

I think abs() is fine; there is no risk of overflow from mod; thanks.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2015-04-30 16:55:35 Re: pg_upgrade: quote directory names in delete_old_cluster script
Previous Message Robert Haas 2015-04-30 13:07:45 Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign