pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathandbossart@gmail.com>
To: jian he <jian.universality@gmail.com>
Cc: Joseph Koshakow <koshy44@gmail.com>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Matthew Kim <matthewkmkim@gmail.com>
Cc: Alexander Lakhin <exclusion@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Andres Freund <andres@anarazel.de>
Subject: Re: Remove dependence on integer wrapping
Date: Thu, 15 Aug 2024 13:45:48 -0500
Message-ID: <Zr5M3KxOZlEZRZIN@nathan> (raw)
In-Reply-To: <CACJufxH-uLR5SnnmVbGYj7Oy90zF_pYV3G_HxfbJ6Lu3XKGXxQ@mail.gmail.com>
References: <CACJufxHNwqoXoP91a-2D3NytrurTSK_+-hd+XeVCYAbk2F0Uhw@mail.gmail.com>
	<CAAvxfHfuxiMG4_YB5oBmJtK7mQx6FRKcUhNueXGwKT6_r=4W_Q@mail.gmail.com>
	<CACJufxFUKTQx8wUpxtRPT31D+a7fNxAL_A_-S4XaR-oZkKEgxA@mail.gmail.com>
	<ZrvUOkL19KHEH2sb@nathan>
	<ZrwfgNyDXy99NUOS@nathan>
	<875ad3ec-f216-487e-baad-cdbaf32c1fcf@iki.fi>
	<ZrznaJTIOPgSjEJ7@nathan>
	<CAAvxfHc2Smk92cJX4aUju1AdW_RpNN8csEj5rvf29b-YFHRmfQ@mail.gmail.com>
	<Zrz0Zv4PVFxieEii@nathan>
	<CACJufxH-uLR5SnnmVbGYj7Oy90zF_pYV3G_HxfbJ6Lu3XKGXxQ@mail.gmail.com>

On Thu, Aug 15, 2024 at 02:56:00PM +0800, jian he wrote:
> i am confused with
> "
> +#elif defined(HAVE_INT128)
> + uint128 res = -((int128) a);
> "
> I thought "unsigned" means non-negative, therefore uint128 means non-negative.
> therefore "int128  res = -((int128) a);" makes sense to me.

Ah, that's a typo, thanks for pointing it out.

> also in HAVE_INT128 branch
> do we need cast int128 to int64, like
> 
> *result = (int64) res;

I don't think we need an explicit cast here since *result is known to be an
int64.  But it certainly wouldn't hurt anything...

-- 
nathan





view thread (85+ messages)  latest in thread

Message-ID: <Zr5M3KxOZlEZRZIN@nathan>
Permalink:  ../Zr5M3KxOZlEZRZIN@nathan/
Also on:    postgresql.org/message-id/Zr5M3KxOZlEZRZIN@nathan

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: nathandbossart@gmail.com, jian.universality@gmail.com, koshy44@gmail.com, hlinnaka@iki.fi, matthewkmkim@gmail.com, exclusion@gmail.com, tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org, andres@anarazel.de
  Subject: Re: Remove dependence on integer wrapping
  In-Reply-To: <Zr5M3KxOZlEZRZIN@nathan>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox