220 40529 <CABPJVnTNih2bKvp6rVCWBpnv06KYuXDs3M0HwZSU_JPV3oG=8g@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: John McFarlane <john@mcfarlane.name>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Function to compute the absolute value of any
 integral value including signed minimums
Date: Sun, 14 Oct 2018 16:17:53 +0100
Lines: 115
Approved: news@gmane.org
Message-ID: <CABPJVnTNih2bKvp6rVCWBpnv06KYuXDs3M0HwZSU_JPV3oG=8g@mail.gmail.com>
References: <3f8200be-918a-44a0-a412-6f8f43da1c51@isocpp.org>
 <CABPJVnS+UYT9Q-6X3Y_t043==ND38cyA5048c1HjbVkX8q3cEw@mail.gmail.com> <3a5821ae-c386-46b4-8e73-4bff8764679c@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="000000000000d2f2be057831d326"
X-Trace: blaine.gmane.org 1539530163 30159 195.159.176.226 (14 Oct 2018 15:16:03 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 14 Oct 2018 15:16:03 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDS7B7WQUYOBBL54RXPAKGQERFDD6UY@isocpp.org Sun Oct 14 17:15:58 2018
Return-path: <std-proposals+bncBDS7B7WQUYOBBL54RXPAKGQERFDD6UY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-it1-f198.google.com ([209.85.166.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDS7B7WQUYOBBL54RXPAKGQERFDD6UY@isocpp.org>)
	id 1gBi7a-0007iC-LH
	for gclcip-std-proposals@m.gmane.org; Sun, 14 Oct 2018 17:15:58 +0200
Original-Received: by mail-it1-f198.google.com with SMTP id m123-v6sf19006554ith.5
        for <gclcip-std-proposals@m.gmane.org>; Sun, 14 Oct 2018 08:18:09 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1539530288; cv=pass;
        d=google.com; s=arc-20160816;
        b=pKFhYeRuX3eZ3y//2BO1WYfirY1vhlRuMn/QPP8zo66w98vLnVeEjnW18eTTQ48hqR
         cMJNf8M4EdGw4z73dhCuax8Qci/sSpBBjder0F9LwI1RPUw78VAkDv58SZPK0SalTa64
         Eie8lTgkWjM44jTNqWiDvgjVbBNeoHgujshoufuMiAcKazTYNlfU6ckQ0wQSuM1SWunt
         CYZEmxFWuWAUDUE23MltucwelVNoyWWDgQeUJ78adL/OHtyiiY/Uw0Q4C/xzOOMVRfuy
         l/gSKxfYMHF5MseSp38WpWP65K6jtmdn7oHf49hZoUxP6tpFXf6WdyLzg+fh5fV7/aQ5
         V4Yw==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:in-reply-to:references:mime-version:dkim-signature;
        bh=CoW34oRa1OOvLMrN3+2H1dd6/HRdkDvvwiHe9OHNfU4=;
        b=uGOkaVfEypVv1bNS8drjvsziqa4Da1PqLa6c1C3KwurjPwuF97gFnv991wLWlVuW9Z
         VM/R8c3ZAojGQrj0K8exZIFRbZojy4QNAHADidoIRT0ncRSq6quoSc+lPQPsWwPoDx3w
         xYEj9+Qd2aG9X+udT6zdfXVKY68i6j0JyrHQG100q6y+tMflnGRZkPwq2aEyUf7tdW2d
         RnjW5qYsYmeSVw4A69syNrWOX/BRbEU2bfY7HnFe15Spx4jxiXYumO3aywjHwVu4cbdN
         I+FptEncYGX763tNKVICHtqCN2uQNr0msjCXjYUU09Mgk347/5zxQByFBadCIRWotAb7
         H+KA==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=pass (google.com: domain of mcfarlane.john@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=mcfarlane.john@gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:references:in-reply-to:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=CoW34oRa1OOvLMrN3+2H1dd6/HRdkDvvwiHe9OHNfU4=;
        b=vFUIb/6tJA31durIYg/Pr1VpDHcVZxQVPuonxhx/7yg9Oix2IHRfbzyQfogk2xPEqJ
         8+O0jr11jQrR6G6B3m7c6DafJTw+dYp2B2UidnJoeur/9TTPdH4FcQYwcMwc6OvWndk9
         H3uP2DRct0MZEE8CCQhy5HH0DPxWoOU+urFxbTqJ/KWurRU6pYCrpGEujoHGOjrDqTwC
         z4AA1YO2+wUp0OHpzIki813q5sCL7PcybXMrdd2/yGd8ROtYlnDDc+NHcSe36od4h04q
         VR8akxmevElYyTEWXTHsxcTZLZH7ZTdq5SkWyMVOw92GYXc9ZUx7lObpzAjF+uLET022
         ldDQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=CoW34oRa1OOvLMrN3+2H1dd6/HRdkDvvwiHe9OHNfU4=;
        b=aEll1NpffhtQcH8SvLp9OHszGX10mQwjXkwHZplMZnBjqHgFpFmEY//T/0bVEip7Rd
         EIlOLr5Qn9Gh2uxfz9nccYw/t3dJzN4jWxvOfcqdthtpp6KUBYeYn+T113cwhWOkMSyq
         vI82NjerMVwtvlVFCjT0M++31mAzE3eHXF4wDngid9jIFocnrW3OJsm5I7qFWCyKQ9Fy
         JPceAa3OlM8Usi432k3fB8BSm2iRF+FfdvOggmDjzkbI+2gDYct1I/QxPH3h39SqHadN
         9guYcYZUP2eeInOlRHii+wjkzN60yYiSf4baFLbJydDzC63ufaWZ2UmEL49w0IsXaEGR
         auHQ==
X-Gm-Message-State: ABuFfohTn4zs3LmFK05ZHh9S/UY7dD54oFlCPYd6paL8ZUR/zJKH1Jdi
	R4PsVlps9l2UYi6gpZa/xsk=
X-Google-Smtp-Source: ACcGV60+EquL1Zya5Nu5Vg+XnYUwUqjIvQLF5HG6IJS0hPyaBaY1lVZtClCMKluoTwcp4WNStlJT6A==
X-Received: by 2002:a02:56d0:: with SMTP id u77-v6mr11833785jad.18.1539530288835;
        Sun, 14 Oct 2018 08:18:08 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a02:76d4:: with SMTP id z203-v6ls6107262jab.5.gmail; Sun, 14
 Oct 2018 08:18:06 -0700 (PDT)
X-Received: by 2002:a02:4c85:: with SMTP id q5-v6mr11338825jad.54.1539530286907;
        Sun, 14 Oct 2018 08:18:06 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1539530286; cv=none;
        d=google.com; s=arc-20160816;
        b=zblwl5zlarTM6Kpfo8bTwyEM2/vscc3oR5yoF2KtNqDOboJGJNN0ne895hL9fN9KI8
         BjLXvowOl1BdemgdxiPWXHX6++feu0GsQ+odfs64lH4eMBP7gOHVsi0I084YknzqMHgz
         I+Wt0lhtVLCus69jBzrBdZQfbo7Oz8cxWskMcSuddjcaqx6VXktwLaTHJQ097Ljllbb4
         s587Hs6y9AIJe9GrUFwvbVqWVnAWZndb/13GlkEKG1CYTNm/umDiRbpFPBPC1pX2PkPI
         jitJuTnY/JjEmsReCYOLlkmRFtiQIUKdwmiQCueF2sYkRz/iqXoETmLQ/YDz5YI3INGk
         80jA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:in-reply-to:references:mime-version;
        bh=aVJ617oeQZuGVAyzBUTgwYoF+UOuvinpKVSai+trHBY=;
        b=aUlHSdve0Q3qE1bgXwh2GSIXcR0GCELgahitUrBlFsXGaxERhyFQPBB0vQZad3REYc
         M8q27in6KgHKPF/zT5i8kv53bxETc3Zc5n8Y7+neXbS8H4WIKZPs+9lHWQNr2RrDrSAh
         HkeGPyJTfyA+gvputPgwClJp/AgoauDGgr79xkr9/98nQoES9kZqJaRNetB5mLG0E2pK
         hOn9zOvHoILceNE6HsM3J8NtLsFfRKd8EKilXBL18smst5or4r1utuZEkIIC//OnoQ0q
         TbfqbDkmA6IS4woHGwa/vSdqP3jCclSvzwPnqv+lP/1xrZm5hqMZ2+1iyDDcnuomNcCS
         UHIQ==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=pass (google.com: domain of mcfarlane.john@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=mcfarlane.john@gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id j201-v6sor13330118itj.5.2018.10.14.08.18.06
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Sun, 14 Oct 2018 08:18:06 -0700 (PDT)
Received-SPF: pass (google.com: domain of mcfarlane.john@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 2002:a24:b90a:: with SMTP id w10-v6mr12082911ite.101.1539530286099;
 Sun, 14 Oct 2018 08:18:06 -0700 (PDT)
In-Reply-To: <3a5821ae-c386-46b4-8e73-4bff8764679c@isocpp.org>
X-Original-Sender: john@mcfarlane.name
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of mcfarlane.john@gmail.com designates 209.85.220.41 as permitted
 sender) smtp.mailfrom=mcfarlane.john@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:40529
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40529>

--000000000000d2f2be057831d326
Content-Type: text/plain; charset="UTF-8"

On Sun, Oct 14, 2018, 03:31 Bengt Gustafsson <bengt.gustafsson@beamways.com>
wrote:

> For me the motivation for uabs() would more be to avoid unsigned/signed
> mismatch errors by getting the result as an unsigned (which we know it
> conceptually is after abs).
>

I consider a number being positive as different to a number being unsigned.
I'd rather those two things (conversion and absolute value) remained
separate concerns.

>
> This is very similar to the annoyance of floor, round and ceil returning
> floats which we know have integer values, forcing us to write int(round(x))
> when using this with other ints to avoid compiler warnings. I think I saw
> something about new floor<int>() and similar functions being proposed, so
> why not uabs?
>

I'm less adverse to abs<unsigned>() because the two concerns are more
apparent but only slightly.

If you're converting a float to an int, a necessary detail is how to
approximate fractional values. So a convert<int, floor_tag>() starts to
become palatable. p0105 proposed something similar. I'm not familiar with
the floor function you mention.

>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/3a5821ae-c386-46b4-8e73-4bff8764679c%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/3a5821ae-c386-46b4-8e73-4bff8764679c%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CABPJVnTNih2bKvp6rVCWBpnv06KYuXDs3M0HwZSU_JPV3oG%3D8g%40mail.gmail.com.

--000000000000d2f2be057831d326
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<br><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Sun, Oct 14, 2018, 0=
3:31 Bengt Gustafsson &lt;<a href=3D"mailto:bengt.gustafsson@beamways.com">=
bengt.gustafsson@beamways.com</a>&gt; wrote:<br></div><blockquote class=3D"=
gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-=
left:1ex"><div dir=3D"ltr">For me the motivation for uabs() would more be t=
o avoid unsigned/signed mismatch errors by getting the result as an unsigne=
d (which we know it conceptually is after abs).</div></blockquote></div><di=
v><br></div><div>I consider a number being positive as different to a numbe=
r being unsigned. I&#39;d rather those two things (conversion and absolute =
value)=C2=A0remained separate concerns.<br></div><div class=3D"gmail_quote"=
><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><br></div><div>This i=
s very similar to the annoyance of floor, round and ceil returning floats w=
hich we know have integer values, forcing us to write int(round(x)) when us=
ing this with other ints to avoid compiler warnings. I think I saw somethin=
g about new floor&lt;int&gt;() and similar functions being proposed, so why=
 not uabs?</div></div></blockquote></div><div><br></div><div>I&#39;m less a=
dverse to abs&lt;unsigned&gt;() because the two concerns are more apparent =
but only slightly.=C2=A0</div><div><br></div><div>If you&#39;re converting =
a float to an int, a necessary detail is how to approximate fractional valu=
es. So a convert&lt;int, floor_tag&gt;() starts to become palatable. p0105 =
proposed something similar. I&#39;m not familiar with the floor function yo=
u mention.</div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote=
" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><=
div dir=3D"ltr"><div><br></div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/3a5821ae-c386-46b4-8e73-4bff8764679c%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/3a5821ae-c386-=
46b4-8e73-4bff8764679c%40isocpp.org</a>.<br>
</blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CABPJVnTNih2bKvp6rVCWBpnv06KYuXDs3M0H=
wZSU_JPV3oG%3D8g%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CABPJVnTNih2bKv=
p6rVCWBpnv06KYuXDs3M0HwZSU_JPV3oG%3D8g%40mail.gmail.com</a>.<br />

--000000000000d2f2be057831d326--

.
