C++ Logo

std-proposals

Advanced search

[std-proposals] std::sign

From: blacktea hamburger <greenteahamburger_at_[hidden]>
Date: Sun, 16 Oct 2022 16:15:31 +0800
See https://en.m.wikipedia.org/wiki/Sign_function.

It is useful in certain situations, such as for rational numbers.
[ratio.ratio]/2.1:

num shall have the value sign(N) * sign(D) * abs(N) / gcd.

The signature of it should be:

constexpr int sign(*floating-point-type* x);

Received on 2022-10-16 08:16:03