Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit b8fb84c

Browse files
WalterBrightdlang-bot
authored andcommitted
fabs: make it pure, match it to std.math.fabs
1 parent cc1ed93 commit b8fb84c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/core/math.d

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,24 @@ unittest {
135135
}
136136

137137
/*******************************
138-
* Returns |x|
139-
*
138+
* Compute the absolute value.
140139
* $(TABLE_SV
141140
* $(TR $(TH x) $(TH fabs(x)))
142141
* $(TR $(TD $(PLUSMN)0.0) $(TD +0.0) )
143142
* $(TR $(TD $(PLUSMN)$(INFIN)) $(TD +$(INFIN)) )
144143
* )
144+
* It is implemented as a compiler intrinsic.
145+
* Params:
146+
* x = floating point value
147+
* Returns: |x|
148+
* References: equivalent to `std.math.fabs`
145149
*/
146-
float fabs(float x); /* intrinsic */
147-
double fabs(double x); /* intrinsic */ /// ditto
148-
real fabs(real x); /* intrinsic */ /// ditto
150+
@safe pure nothrow @nogc
151+
{
152+
float fabs(float x);
153+
double fabs(double x); /// ditto
154+
real fabs(real x); /// ditto
155+
}
149156

150157
/**********************************
151158
* Rounds x to the nearest integer value, using the current rounding

0 commit comments

Comments
 (0)