mirror of
https://github.com/pocketpy/pocketpy
synced 2026-02-04 06:30:17 +00:00
Update math.c
This commit is contained in:
parent
08f39b8444
commit
e82b2b98cf
@ -18,6 +18,15 @@
|
|||||||
return true; \
|
return true; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ONE_ARG_BOOL_FUNC(name, func) \
|
||||||
|
static bool math_##name(int argc, py_Ref argv) { \
|
||||||
|
PY_CHECK_ARGC(1); \
|
||||||
|
double x; \
|
||||||
|
if(!py_castfloat(py_arg(0), &x)) return false; \
|
||||||
|
py_newbool(py_retval(), func(x)); \
|
||||||
|
return true; \
|
||||||
|
}
|
||||||
|
|
||||||
#define TWO_ARG_FUNC(name, func) \
|
#define TWO_ARG_FUNC(name, func) \
|
||||||
static bool math_##name(int argc, py_Ref argv) { \
|
static bool math_##name(int argc, py_Ref argv) { \
|
||||||
PY_CHECK_ARGC(2); \
|
PY_CHECK_ARGC(2); \
|
||||||
@ -69,9 +78,9 @@ static bool math_gcd(int argc, py_Ref argv) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ONE_ARG_FUNC(isfinite, isfinite)
|
ONE_ARG_BOOL_FUNC(isfinite, isfinite)
|
||||||
ONE_ARG_FUNC(isinf, isinf)
|
ONE_ARG_BOOL_FUNC(isinf, isinf)
|
||||||
ONE_ARG_FUNC(isnan, isnan)
|
ONE_ARG_BOOL_FUNC(isnan, isnan)
|
||||||
|
|
||||||
static bool math_isclose(int argc, py_Ref argv) {
|
static bool math_isclose(int argc, py_Ref argv) {
|
||||||
PY_CHECK_ARGC(2);
|
PY_CHECK_ARGC(2);
|
||||||
@ -206,4 +215,5 @@ void pk__add_module_math() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#undef ONE_ARG_FUNC
|
#undef ONE_ARG_FUNC
|
||||||
#undef TWO_ARG_FUNC
|
#undef ONE_ARG_BOOL_FUNC
|
||||||
|
#undef TWO_ARG_FUNC
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user