Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dab6cb8 commit 71260b8Copy full SHA for 71260b8
5 files changed
Doc/lib/libmath.tex
@@ -93,6 +93,10 @@ \section{\module{math} ---
93
Return \code{\var{x}**\var{y}}.
94
\end{funcdesc}
95
96
+\begin{funcdesc}{rint}{x, y}
97
+Return the integer nearest to \var{x} as a real.
98
+\end{funcdesc}
99
+
100
\begin{funcdesc}{sin}{x}
101
Return the sine of \var{x}.
102
Include/mymath.h
@@ -48,6 +48,7 @@ extern double hypot Py_PROTO((double, double));
48
#undef log
49
#undef log10
50
#undef pow
51
+#undef rint
52
#undef sin
53
#undef sinh
54
#undef sqrt
@@ -67,6 +68,7 @@ extern double hypot Py_PROTO((double, double));
67
68
#define log logd
69
#define log10 log10d
70
#define pow powd
71
+#define rint rintd
72
#define sin sind
73
#define sinh sinhd
74
#define sqrt sqrtd
Lib/test/output/test_math
@@ -19,6 +19,7 @@ log
19
log10
20
modf
21
pow
22
+rint
23
sin
24
sinh
25
sqrt
Lib/test/test_math.py
@@ -129,6 +129,12 @@ def testmodf(name, (v1, v2), (e1, e2)):
129
testit('pow(2,1)', math.pow(2,1), 2)
130
testit('pow(2,-1)', math.pow(2,-1), 0.5)
131
132
+print 'rint'
133
+testit('rint(0.7)', math.rint(0.7), 1)
134
+testit('rint(-0.3)', math.rint(-0.3), 0)
135
+testit('rint(2.5)', math.rint(2.5), 2)
136
+testit('rint(3.5)', math.rint(3.5), 4)
137
138
print 'sin'
139
testit('sin(0)', math.sin(0), 0)
140
testit('sin(pi/2)', math.sin(math.pi/2), 1)
Modules/mathmodule.c
@@ -156,6 +156,8 @@ FUNC2(math_pow, power, math_pow_doc,
156
FUNC2(math_pow, pow, math_pow_doc,
157
"pow(x,y)\n\nReturn x**y.")
158
#endif
159
+FUNC1(math_rint, rint, math_rint_doc,
160
+ "rint(x)\n\nReturn the integer nearest to x as a real.")
161
FUNC1(math_sin, sin, math_sin_doc,
162
"sin(x)\n\nReturn the sine of x.")
163
FUNC1(math_sinh, sinh, math_sinh_doc,
@@ -267,6 +269,7 @@ static PyMethodDef math_methods[] = {
267
269
{"log10", math_log10, 0, math_log10_doc},
268
270
{"modf", math_modf, 0, math_modf_doc},
271
{"pow", math_pow, 0, math_pow_doc},
272
+ {"rint", math_rint, 0, math_rint_doc},
273
{"sin", math_sin, 0, math_sin_doc},
274
{"sinh", math_sinh, 0, math_sinh_doc},
275
{"sqrt", math_sqrt, 0, math_sqrt_doc},
0 commit comments