Skip to content

Commit

Permalink
Make 'proc sgn' and 'proc bigint.sgn' overloads unstable
Browse files Browse the repository at this point in the history
---
Signed-off-by: Michael Ferguson <[email protected]>
  • Loading branch information
mppf committed Mar 11, 2024
1 parent 8831f71 commit a9d4865
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/standard/AutoMath.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -580,24 +580,28 @@ module AutoMath {
/* Returns the signum function of the integer argument `x`:
1 if positive, -1 if negative, 0 if zero.
*/
@unstable("sgn is unstable and may change its name and return type in the future")
inline proc sgn(x : int(?w)): int(8) do
return ((x > 0) : int(8) - (x < 0) : int(8)) : int(8);

/* Returns the signum function of the unsigned integer argument `x`:
1 if positive, -1 if negative, 0 if zero.
*/
@unstable("sgn is unstable and may change its name and return type in the future")
inline proc sgn(x : uint(?w)): uint(8) do
return (x > 0) : uint(8);

/* Returns the signum function of the integer param argument `x`:
1 if positive, -1 if negative, 0 if zero.
*/
@unstable("sgn is unstable and may change its name and return type in the future")
proc sgn(param x : integral) param do
return if x > 0 then 1 else if x == 0 then 0 else -1;

/* Returns the signum function of the real argument `x`:
1 if positive, -1 if negative, 0 if zero.
*/
@unstable("sgn is unstable and may change its name and return type in the future")
inline proc sgn(x : real(?w)): int(8) do
return ((x > 0.0) : int(8) - (x < 0.0) : int(8)) : int(8);

Expand Down
1 change: 1 addition & 0 deletions modules/standard/BigInteger.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -3686,6 +3686,7 @@ module BigInteger {
:proc:`GMP.mpz_sgn` and
`mpz_sgn <https://gmplib.org/manual/Integer-Comparisons#index-mpz_005fsgn>`_.
*/
@unstable("bigint.sgn is unstable and may change its name and return type in the future")
proc bigint.sgn() : int {
const this_ = this.localize();
var ret : c_int;
Expand Down

0 comments on commit a9d4865

Please sign in to comment.