2015-01-07 01:26:14 +08:00
|
|
|
|
/*
|
|
|
|
|
* _util.cpp
|
|
|
|
|
*
|
|
|
|
|
* Created on: 2011-12-4
|
|
|
|
|
* Author: fasiondog
|
|
|
|
|
*/
|
|
|
|
|
|
2023-09-24 02:46:04 +08:00
|
|
|
|
#include <hikyuu/utilities/arithmetic.h>
|
2023-10-09 23:25:20 +08:00
|
|
|
|
#include "pybind_utils.h"
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
|
|
|
|
using namespace hku;
|
2023-12-27 02:16:10 +08:00
|
|
|
|
namespace py = pybind11;
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
2023-12-27 02:16:10 +08:00
|
|
|
|
void export_util(py::module& m) {
|
2024-02-28 02:47:10 +08:00
|
|
|
|
m.def("roundEx", roundEx<float>, py::arg("number"), py::arg("ndigits") = 0);
|
2024-02-27 16:38:12 +08:00
|
|
|
|
m.def("roundEx", roundEx<double>, py::arg("number"), py::arg("ndigits") = 0,
|
|
|
|
|
R"(roundEx(number[, ndigits=0])
|
|
|
|
|
|
|
|
|
|
四舍五入,ROUND_HALF_EVEN 银行家舍入法
|
|
|
|
|
|
|
|
|
|
:param float number 待四舍五入的数据
|
|
|
|
|
:param int ndigits 保留小数位数
|
|
|
|
|
:rype: float)");
|
|
|
|
|
|
2024-02-28 02:47:10 +08:00
|
|
|
|
m.def("roundUp", roundUp<float>, py::arg("number"), py::arg("ndigits") = 0);
|
|
|
|
|
m.def("roundUp", roundUp<double>, py::arg("number"), py::arg("ndigits") = 0,
|
2023-12-27 02:16:10 +08:00
|
|
|
|
R"(roundUp(number[, ndigits=0])
|
2020-07-04 00:15:54 +08:00
|
|
|
|
|
|
|
|
|
向上截取,如10.1截取后为11
|
|
|
|
|
|
|
|
|
|
:param float number 待处理数据
|
|
|
|
|
:param int ndigits 保留小数位数
|
|
|
|
|
:rtype: float)");
|
|
|
|
|
|
2024-02-28 02:47:10 +08:00
|
|
|
|
m.def("roundDown", roundDown<float>, py::arg("number"), py::arg("ndigits") = 0);
|
|
|
|
|
m.def("roundDown", roundDown<double>, py::arg("number"), py::arg("ndigits") = 0,
|
2023-12-27 02:16:10 +08:00
|
|
|
|
R"(roundDown(number[, ndigits=0])
|
2020-07-04 00:15:54 +08:00
|
|
|
|
|
|
|
|
|
向下截取,如10.1截取后为10
|
|
|
|
|
|
|
|
|
|
:param float number 待处理数据
|
|
|
|
|
:param int ndigits 保留小数位数
|
|
|
|
|
:rtype: float)");
|
2015-01-07 01:26:14 +08:00
|
|
|
|
}
|