File 6602-stdlib-Add-math-tau-0-constant-as-2-pi.patch of Package erlang

From 6aebff0d5a37d2c95b820bae7d58713b74c9fce6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Niemier?= <lukasz@niemier.pl>
Date: Mon, 19 Dec 2022 21:00:23 +0100
Subject: [PATCH 2/2] stdlib: Add math:tau/0 constant as 2*pi

---
 lib/stdlib/doc/src/math.xml    | 10 ++++++++++
 lib/stdlib/src/math.erl        |  6 ++++--
 lib/stdlib/test/math_SUITE.erl |  9 +++++++--
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/lib/stdlib/doc/src/math.xml b/lib/stdlib/doc/src/math.xml
index a3276655be..c81c882971 100644
--- a/lib/stdlib/doc/src/math.xml
+++ b/lib/stdlib/doc/src/math.xml
@@ -109,6 +109,16 @@ erf(X) = 2/sqrt(pi)*integral from 0 to X of exp(-t*t) dt.</pre>
       </desc>
     </func>
 
+    <func>
+      <name name="tau" arity="0" since="OTP 25.3"/>
+      <fsummary>Ratio of the circumference of a circle to its radius.</fsummary>
+      <desc>
+        <p>Ratio of the circumference of a circle to its radius.</p>
+        <p>This constant is equivalent to a full turn when described in radians.</p>
+        <p>The same as <c>2 * pi()</c>.</p>
+      </desc>
+    </func>
+
   </funcs>
 
   <section>
diff --git a/lib/stdlib/src/math.erl b/lib/stdlib/src/math.erl
index 3a3b384d8f..9f267d6558 100644
--- a/lib/stdlib/src/math.erl
+++ b/lib/stdlib/src/math.erl
@@ -19,7 +19,7 @@
 %%
 -module(math).
 
--export([pi/0]).
+-export([pi/0,tau/0]).
 
 %%% BIFs
 
@@ -154,5 +154,7 @@ tanh(_) ->
 %%% End of BIFs
 
 -spec pi() -> float().
-
 pi() -> 3.1415926535897932.
+
+-spec tau() -> float().
+tau() -> 6.2831853071795864.
diff --git a/lib/stdlib/test/math_SUITE.erl b/lib/stdlib/test/math_SUITE.erl
index 5804c5bb46..3637cbd1fe 100644
--- a/lib/stdlib/test/math_SUITE.erl
+++ b/lib/stdlib/test/math_SUITE.erl
@@ -28,7 +28,7 @@
 	 init_per_testcase/2, end_per_testcase/2]).
 
 %% Test cases
--export([floor_ceil/1]).
+-export([floor_ceil/1, constants/1]).
 
 
 suite() ->
@@ -36,7 +36,7 @@ suite() ->
      {timetrap,{minutes,1}}].
 
 all() ->
-    [floor_ceil].
+    [floor_ceil, constants].
 
 groups() ->
     [].
@@ -60,6 +60,11 @@ init_per_testcase(_Case, Config) ->
 end_per_testcase(_Case, _Config) ->
     ok.
 
+constants(_Config) ->
+    3.1415926535897932 = math:pi(),
+    6.2831853071795864 = math:tau(),
+    ok.
+
 floor_ceil(_Config) ->
     MinusZero = 0.0/(-1.0),
     -43.0 = do_floor_ceil(-42.1),
-- 
2.35.3

openSUSE Build Service is sponsored by