Topic: Missing std::sign
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Thu, 21 Aug 2014 10:50:17 -0700 (PDT)
Raw View
------=_Part_500_329625893.1408643417115
Content-Type: text/plain; charset=UTF-8
The math library is missing the signum function.
//Returns 1 if x > 0, 0 if x == 0, or -1 if x < 0
template <typename T> constexpr T sign(T x);
Here are a whole bunch of people arguing about ways to implement it. Be
nice if there was a standard version with optimal efficiency on each
platform.
http://stackoverflow.com/questions/1903954/is-there-a-standard-sign-function-signum-sgn-in-c-c
It is possible to add new functions to the <cmath> header without getting
them in the C standard first?
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_500_329625893.1408643417115
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The math library is missing the signum function.<br><br>//=
Returns 1 if x > 0, 0 if x =3D=3D 0, or -1 if x < 0<br>template <t=
ypename T> constexpr T sign(T x);<br><br>Here are a whole bunch of peopl=
e arguing about ways to implement it. Be nice if there was a standard versi=
on with optimal efficiency on each platform.<br>http://stackoverflow.com/qu=
estions/1903954/is-there-a-standard-sign-function-signum-sgn-in-c-c<br><br>=
It is possible to add new functions to the <cmath> header without get=
ting them in the C standard first?<br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_500_329625893.1408643417115--
.
Author: Howard Hinnant <howard.hinnant@gmail.com>
Date: Thu, 21 Aug 2014 14:03:22 -0400
Raw View
On Aug 21, 2014, at 1:50 PM, Matthew Fioravante <fmatthew5876@gmail.com> wr=
ote:
> The math library is missing the signum function.
>=20
> //Returns 1 if x > 0, 0 if x =3D=3D 0, or -1 if x < 0
> template <typename T> constexpr T sign(T x);
>=20
> Here are a whole bunch of people arguing about ways to implement it. Be n=
ice if there was a standard version with optimal efficiency on each platfor=
m.
> http://stackoverflow.com/questions/1903954/is-there-a-standard-sign-funct=
ion-signum-sgn-in-c-c
>=20
> It is possible to add new functions to the <cmath> header without getting=
them in the C standard first?
Yes, as long as the spec clearly states that the signature is not guarantee=
d to be available from <math.h>. Unofficially, but from a practical standp=
oint, we own <cmath>, and the C committee owns <math.h>. Whenever either o=
f the two committees tries to specify the other's header (and both committe=
es have attempt to do so in the past), a little bit more chaos escapes into=
the universe, and is nearly impossible to recapture. To this day we suffe=
r from such attempts in the past.
Howard
--=20
---=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: Gabriel Dos Reis <gdr@axiomatics.org>
Date: Sat, 23 Aug 2014 13:59:56 -0700
Raw View
Howard Hinnant <howard.hinnant@gmail.com> writes:
| guaranteed to be available from <math.h>. Unofficially, but from a
| practical standpoint, we own <cmath>, and the C committee owns
| <math.h>. Whenever either of the two committees tries to specify the
| other's header (and both committees have attempt to do so in the
| past), a little bit more chaos escapes into the universe, and is
| nearly impossible to recapture. To this day we suffer from such
| attempts in the past.
Amen to that.
Furthermore, LWG should stop Pavlovian reflexive adoption of everything
WG14 invents as <cxxx>. Case in point: <cstdalign>.
-- Gaby
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Wed, 27 Aug 2014 17:13:28 -0700 (PDT)
Raw View
------=_Part_5487_1573500003.1409184808351
Content-Type: text/plain; charset=UTF-8
Maybe it would make sense to have a C++ <math> header which includes
<cmath> and also has C++ specific math functions? Similarly for other
headers. The header <cmath> sounds like a C compatibility header, not the
primary header for the C++ math library.
On Saturday, August 23, 2014 4:59:58 PM UTC-4, Gabriel Dos Reis wrote:
>
> Howard Hinnant <howard....@gmail.com <javascript:>> writes:
>
> | guaranteed to be available from <math.h>. Unofficially, but from a
> | practical standpoint, we own <cmath>, and the C committee owns
> | <math.h>. Whenever either of the two committees tries to specify the
> | other's header (and both committees have attempt to do so in the
> | past), a little bit more chaos escapes into the universe, and is
> | nearly impossible to recapture. To this day we suffer from such
> | attempts in the past.
>
> Amen to that.
>
> Furthermore, LWG should stop Pavlovian reflexive adoption of everything
> WG14 invents as <cxxx>. Case in point: <cstdalign>.
>
> -- Gaby
>
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_5487_1573500003.1409184808351
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Maybe it would make sense to have a C++ <math> heade=
r which includes <cmath> and also has C++ specific math functions? Si=
milarly for other headers. The header <cmath> sounds like a C compati=
bility header, not the primary header for the C++ math library.<br><br>On S=
aturday, August 23, 2014 4:59:58 PM UTC-4, Gabriel Dos Reis wrote:<blockquo=
te class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left:=
1px #ccc solid;padding-left: 1ex;">Howard Hinnant <<a href=3D"javascrip=
t:" target=3D"_blank" gdf-obfuscated-mailto=3D"G-V-DPRqRUcJ" onmousedown=3D=
"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript=
:';return true;">howard....@gmail.com</a>> writes:
<br>
<br>| guaranteed to be available from <math.h>. Unofficially, b=
ut from a
<br>| practical standpoint, we own <cmath>, and the C committee owns
<br>| <math.h>. Whenever either of the two committees tries to =
specify the
<br>| other's header (and both committees have attempt to do so in the
<br>| past), a little bit more chaos escapes into the universe, and is
<br>| nearly impossible to recapture. To this day we suffer from such
<br>| attempts in the past.
<br>
<br>Amen to that.
<br>
<br>Furthermore, LWG should stop Pavlovian reflexive adoption of everything
<br>WG14 invents as <cxxx>. Case in point: <cstdalign>.
<br>
<br>-- Gaby
<br></blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_5487_1573500003.1409184808351--
.
Author: Howard Hinnant <howard.hinnant@gmail.com>
Date: Wed, 27 Aug 2014 21:19:21 -0400
Raw View
On Aug 27, 2014, at 8:13 PM, Matthew Fioravante <fmatthew5876@gmail.com> wr=
ote:
> Maybe it would make sense to have a C++ <math> header which includes <cma=
th> and also has C++ specific math functions? Similarly for other headers. =
The header <cmath> sounds like a C compatibility header, not the primary he=
ader for the C++ math library.
No, just put the C++ specific math functions in <cmath>, and then explicitl=
y state that they do not appear in <math.h> (unless the C committee says ot=
herwise).
We don't need more headers. And there is no problem in the C++ committee a=
dding functionality to <cmath>. We only get in trouble when the C++ commit=
tee adds (or subtracts) functionality to <math.h>, or when the C committee =
adds (or subtracts) functionality to <cmath>.
Howard
--=20
---=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: Gabriel Dos Reis <gdr@axiomatics.org>
Date: Thu, 28 Aug 2014 04:52:49 -0700
Raw View
Howard Hinnant <howard.hinnant@gmail.com> writes:
| On Aug 27, 2014, at 8:13 PM, Matthew Fioravante <fmatthew5876@gmail.com> =
wrote:
|=20
| > Maybe it would make sense to have a C++ <math> header which includes
| > <cmath> and also has C++ specific math functions? Similarly for
| > other headers. The header <cmath> sounds like a C compatibility
| > header, not the primary header for the C++ math library.
|=20
| No, just put the C++ specific math functions in <cmath>, and then
| explicitly state that they do not appear in <math.h> (unless the C
| committee says otherwise).
Agreed. We already have too many C++ headers that do "math" stuff and I
always forget which one to include -- <cmath>, <cstdlib>, <numerics>,
<algorithm>, <complex>, <valarray>, etc.
| We don=E2=80=99t need more headers. And there is no problem in the C++
| committee adding functionality to <cmath>. We only get in trouble
| when the C++ committee adds (or subtracts) functionality to <math.h>,
| or when the C committee adds (or subtracts) functionality to <cmath>.
|=20
| Howard
-- Gaby
--=20
---=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.