File 2081-Add-math-fmod-2-BIF.patch of Package erlang
From e21a6c9ec713219b0aa2b2a4224f97e713d7337f Mon Sep 17 00:00:00 2001
From: Guilherme Andrade <g@gandrade.net>
Date: Tue, 25 Oct 2016 22:05:10 +0100
Subject: [PATCH 1/3] Add math:fmod/2 BIF
Returns the (floating point) remainder of first argument divided
by second argument.
---
erts/emulator/beam/bif.tab | 1 +
erts/emulator/beam/erl_math.c | 5 +++++
lib/stdlib/doc/src/math.xml | 1 +
lib/stdlib/src/math.erl | 8 +++++++-
4 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/erts/emulator/beam/bif.tab b/erts/emulator/beam/bif.tab
index 852b113..32600f4 100644
--- a/erts/emulator/beam/bif.tab
+++ b/erts/emulator/beam/bif.tab
@@ -667,6 +667,7 @@ gcbif erlang:floor/1
bif 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 990fa63..1f270eb 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 70ca6ae..b4f0962 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 1db48cd..3a3b384 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(_) ->
--
2.10.2