源码已经更新在CSDN的码库里:
git clone https://gitcode.com/funsion/CLua.git
在src文件夹下的lmathlib.c 数学库 函数,Standard mathematical library:表明这个C源文件实现了Lua的标准数学库(Standard mathematical library),即提供了与数学相关的API和功能实现。
增加中文版mathlib数学函数名列表,保留英文版mathlib数学函数名列表。
原始的代码为:
static const luaL_Reg mathlib[] = {
{"abs", math_abs},
{"acos", math_acos},
{"asin", math_asin},
{"atan", math_atan},
{"ceil", math_ceil},
{"cos", math_cos},
{"deg", math_deg},
{"exp", math_exp},
{"tointeger", math_toint},
{"floor", math_floor},
{"fmod", math_fmod},
{"ult", math_ult},
{"log", math_log},
{"max", math_max},
{"min", math_min},
{"modf", math_modf},
{"rad", math_rad},
{"sin", math_sin},
{"sqrt", math_sqrt},
{"tan", math_tan},
{"type", math_type},
#if defined(LUA_COMPAT_MATHLIB)
{"atan2", math_atan},
{"cosh", math_cosh},
{"sinh", math_sinh},
{"tanh", math_tanh},
{"pow", math_pow},
{"frexp", math_frexp},
{"ldexp", math_ldexp},
{"log10", math_log10},
#endif
/* placeholders */
{"random", NULL},
{"randomseed", NULL},
{"pi", NULL},
{"huge", NULL},
{"maxinteger", NULL},
{"mininteger", NULL},
{NULL, NULL}
};
更改成以下代码:
static const luaL_Reg mathlib[] = {
{"abs", math_abs}, {"绝对值", math_abs},
{"acos", math_acos}, {"反余弦", math_acos},
{"asin", math_asin}, {"反正弦", math_asin},
{"atan", math_atan}, {"反正切", math_atan},
{"ceil", math_c