aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilherme Andrade <[email protected]>2016-10-25 22:05:10 +0100
committerGuilherme Andrade <[email protected]>2016-11-02 18:55:28 +0000
commite21a6c9ec713219b0aa2b2a4224f97e713d7337f (patch)
tree330e95b1d8328a47d3645031ce1ddaf0e2b63496
parent37122019312c94df2ca0347417ca50dd8daf1084 (diff)
downloadotp-e21a6c9ec713219b0aa2b2a4224f97e713d7337f.tar.gz
otp-e21a6c9ec713219b0aa2b2a4224f97e713d7337f.tar.bz2
otp-e21a6c9ec713219b0aa2b2a4224f97e713d7337f.zip
Add math:fmod/2 BIF
Returns the (floating point) remainder of first argument divided by second argument.
-rw-r--r--erts/emulator/beam/bif.tab1
-rw-r--r--erts/emulator/beam/erl_math.c5
-rw-r--r--lib/stdlib/doc/src/math.xml1
-rw-r--r--lib/stdlib/src/math.erl8
4 files changed, 14 insertions, 1 deletions
diff --git a/erts/emulator/beam/bif.tab b/erts/emulator/beam/bif.tab
index 852b1135fe..32600f4338 100644
--- a/erts/emulator/beam/bif.tab
+++ b/erts/emulator/beam/bif.tab
@@ -667,6 +667,7 @@ gcbif erlang:floor/1
gcbif erlang:ceil/1
bif math:floor/1
bif math:ceil/1
+bif math:fmod/2
#
# Obsolete
diff --git a/erts/emulator/beam/erl_math.c b/erts/emulator/beam/erl_math.c
index 990fa63bd4..1f270eb55f 100644
--- a/erts/emulator/beam/erl_math.c
+++ b/erts/emulator/beam/erl_math.c
@@ -256,3 +256,8 @@ BIF_RETTYPE math_floor_1(BIF_ALIST_1)
{
return math_call_1(BIF_P, floor, BIF_ARG_1);
}
+
+BIF_RETTYPE math_fmod_2(BIF_ALIST_2)
+{
+ return math_call_2(BIF_P, fmod, BIF_ARG_1, BIF_ARG_2);
+}
diff --git a/lib/stdlib/doc/src/math.xml b/lib/stdlib/doc/src/math.xml
index 70ca6ae78e..b4f096217a 100644
--- a/lib/stdlib/doc/src/math.xml
+++ b/lib/stdlib/doc/src/math.xml
@@ -62,6 +62,7 @@
<name name="cosh" arity="1"/>
<name name="exp" arity="1"/>
<name name="floor" arity="1"/>
+ <name name="fmod" arity="2"/>
<name name="log" arity="1"/>
<name name="log10" arity="1"/>
<name name="log2" arity="1"/>
diff --git a/lib/stdlib/src/math.erl b/lib/stdlib/src/math.erl
index 1db48cd0a2..3a3b384d8f 100644
--- a/lib/stdlib/src/math.erl
+++ b/lib/stdlib/src/math.erl
@@ -26,7 +26,8 @@
-export([sin/1, cos/1, tan/1, asin/1, acos/1, atan/1, atan2/2, sinh/1,
cosh/1, tanh/1, asinh/1, acosh/1, atanh/1, exp/1, log/1,
log2/1, log10/1, pow/2, sqrt/1, erf/1, erfc/1,
- ceil/1, floor/1]).
+ ceil/1, floor/1,
+ fmod/2]).
-spec acos(X) -> float() when
X :: number().
@@ -99,6 +100,11 @@ exp(_) ->
floor(_) ->
erlang:nif_error(undef).
+-spec fmod(X, Y) -> float() when
+ X :: number(), Y :: number().
+fmod(_, _) ->
+ erlang:nif_error(undef).
+
-spec log(X) -> float() when
X :: number().
log(_) ->