diff --git a/native/cocos/scripting/js-bindings/jswrapper/Value.cpp b/native/cocos/scripting/js-bindings/jswrapper/Value.cpp index 23fab51d09..177e8490ee 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/Value.cpp +++ b/native/cocos/scripting/js-bindings/jswrapper/Value.cpp @@ -487,7 +487,11 @@ namespace se { else if (_type == Type::Number) { char tmp[350] = {0}; - snprintf(tmp, sizeof(tmp), "%lf", _u._number); + double remainder = fmod(_u._number, 1.0); + if (std::abs(remainder) > 0) + snprintf(tmp, sizeof(tmp), "%lf", _u._number); + else + snprintf(tmp, sizeof(tmp), "%d", (int32_t)_u._number); ret = tmp; } else if (_type == Type::Object)