mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
some fix
This commit is contained in:
parent
dcb5f38ddf
commit
335d35cbc9
@ -84,7 +84,6 @@ struct NumberTraits<4> {
|
|||||||
using int_t = int32_t;
|
using int_t = int32_t;
|
||||||
static constexpr int_t kMaxSmallInt = (1 << 28) - 1;
|
static constexpr int_t kMaxSmallInt = (1 << 28) - 1;
|
||||||
static constexpr int_t kMinSmallInt = is_negative_shift_well_defined() ? -(1 << 28) : 0;
|
static constexpr int_t kMinSmallInt = is_negative_shift_well_defined() ? -(1 << 28) : 0;
|
||||||
static constexpr float_t kEpsilon = (float_t)1e-4;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -92,7 +91,6 @@ struct NumberTraits<8> {
|
|||||||
using int_t = int64_t;
|
using int_t = int64_t;
|
||||||
static constexpr int_t kMaxSmallInt = (1ll << 60) - 1;
|
static constexpr int_t kMaxSmallInt = (1ll << 60) - 1;
|
||||||
static constexpr int_t kMinSmallInt = is_negative_shift_well_defined() ? -(1ll << 60) : 0;
|
static constexpr int_t kMinSmallInt = is_negative_shift_well_defined() ? -(1ll << 60) : 0;
|
||||||
static constexpr float_t kEpsilon = (float_t)1e-8;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
using Number = NumberTraits<sizeof(void*)>;
|
using Number = NumberTraits<sizeof(void*)>;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace pkpy{
|
namespace pkpy{
|
||||||
|
|
||||||
inline bool isclose(float a, float b){ return std::fabs(a - b) <= NumberTraits<4>::kEpsilon; }
|
inline bool isclose(float a, float b){ return std::fabs(a - b) < 1e-5; }
|
||||||
|
|
||||||
struct Vec2{
|
struct Vec2{
|
||||||
PY_CLASS(Vec2, linalg, vec2)
|
PY_CLASS(Vec2, linalg, vec2)
|
||||||
|
@ -166,7 +166,7 @@ void add_module_math(VM* vm){
|
|||||||
vm->bind_func<2>(mod, "isclose", [](VM* vm, ArgsView args) {
|
vm->bind_func<2>(mod, "isclose", [](VM* vm, ArgsView args) {
|
||||||
f64 a = CAST_F(args[0]);
|
f64 a = CAST_F(args[0]);
|
||||||
f64 b = CAST_F(args[1]);
|
f64 b = CAST_F(args[1]);
|
||||||
return VAR(std::fabs(a - b) <= Number::kEpsilon);
|
return VAR(std::fabs(a - b) < 1e-9);
|
||||||
});
|
});
|
||||||
|
|
||||||
vm->bind_func<1>(mod, "exp", PK_LAMBDA(VAR(std::exp(CAST_F(args[0])))));
|
vm->bind_func<1>(mod, "exp", PK_LAMBDA(VAR(std::exp(CAST_F(args[0])))));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user