Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sefTw-00ARxU-4S for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Aug 2024 18:45:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sefTu-000dzy-Lk for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Aug 2024 18:45:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sefTu-000dyh-B4 for pgsql-hackers@lists.postgresql.org; Thu, 15 Aug 2024 18:45:54 +0000 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sefTr-004tv2-Pi for pgsql-hackers@lists.postgresql.org; Thu, 15 Aug 2024 18:45:53 +0000 Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-7093c94435bso594795a34.0 for ; Thu, 15 Aug 2024 11:45:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723747551; x=1724352351; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=h4ayJ2lA29fzFCmBVaCP4gatR+cmHnboam+41ouIXx0=; b=LfVCqklqJz7AFkjgQlTuWV1t1NDTO0zpwey1VQu8sA8YLB7uwi/OE4+LFkGIEbZIGp QvSaMKUaefDe6aqaaDdwGTZ2wMbTYonYk2L9hhRgZ919qI0oA7UeBxCD+1lBc1dyLi15 pYUMRGKa2UJJ45cUYm1msItbK9j3J56eroxVKM0kPE4ukTLf4BvO+VUyEH1iLn6osgHR q5OU4e3zNnk13+YVNs8q4rhAuXoTBv8+gafuMSNjIaX7lZhr9MpGoKzbcyLLjloTxJts WtxChBft+lE+M1ncG8BVwBqF4uJQndtKgjNL6k1I9j6AbXaQOPdWnSI5dx6vFNYDwO7S DnlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723747551; x=1724352351; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=h4ayJ2lA29fzFCmBVaCP4gatR+cmHnboam+41ouIXx0=; b=wVw6KMcddwrhrIRe2x/m2CkdnVJLAQZDxhhwV2wXWI3luVmg7IlF2H+ZlGO91J+5HA BaKXllJwaVFRUgMRyjHSQHw2gRFEIWDpynuDCrhe1+gPhjOxcaVY86/Somn5c6pV05iu g1uaGv5Q1Ppqsp2q/Aa8itlPPKxKKAc1CY5wjqwW1ZWTc/6n50Fe2hEoj/AWTlNytUjA ph+fes18Uuvl3pcvQ5+xito7CRejh+P9k8iy0FtjrSifChAbtwBCiUMp3bT+2U+PNShh Najnsz8t51WJ40edBKRBjLRkA/I065m5AkzuK4r1NbW2TIYE2hSIaOtTv7BaBuDLdyjC lTTg== X-Forwarded-Encrypted: i=1; AJvYcCWAnDUzjCtR1afJ03S7inlfGUjwRC4MeHO6YWOrTRDZl4tsLlcvjaXJeuL9Inl+ui1OVtGRA+/hk0EXi74C9Ml+lsvYsTn5Fd5q4uNMXzkF1CfQ X-Gm-Message-State: AOJu0YyUJXp4F3E+clJtEYC3kvdqHJHX64/lrZo1pY1SUf/6Zqoawj7s MQwTcMFkYZVfHz4YnMgt9FYJI8MaN804DreSVgp/y3jj7JcdwQuXFVI9SQ== X-Google-Smtp-Source: AGHT+IFf9jrtsrRKqthr4nFA2KwNp6CxCtz2kCBZ0GQf4TyI0Cg1XHqRnWt0EKjQMtddtjHs5UTWZQ== X-Received: by 2002:a05:6830:268f:b0:709:4cde:cd6b with SMTP id 46e09a7af769-70cac8422b3mr460503a34.9.1723747550708; Thu, 15 Aug 2024 11:45:50 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4ccd6f3db73sm662454173.112.2024.08.15.11.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 11:45:50 -0700 (PDT) Date: Thu, 15 Aug 2024 13:45:48 -0500 From: Nathan Bossart To: jian he Cc: Joseph Koshakow , Heikki Linnakangas , Matthew Kim , Alexander Lakhin , Tom Lane , PostgreSQL Hackers , Andres Freund Subject: Re: Remove dependence on integer wrapping Message-ID: References: <875ad3ec-f216-487e-baad-cdbaf32c1fcf@iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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