数字转字符串范围优化为 JavaScript 的 Number.MAX_SAFE_INTEGER ~ Number.MIN_SAFE_INTEGER

This commit is contained in:
TommyLemon 2024-05-19 23:28:06 +08:00 committed by GitHub
parent 4a2e7f590d
commit aab39ff28d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1077,10 +1077,14 @@ public abstract class AbstractSQLExecutor<T extends Object> implements SQLExecut
}
double v = value.doubleValue();
if (v > Integer.MAX_VALUE || v < Integer.MIN_VALUE) { // 避免前端/客户端拿到精度丢失甚至严重失真的值
// if (v > Integer.MAX_VALUE || v < Integer.MIN_VALUE) { // 避免前端/客户端拿到精度丢失甚至严重失真的值
// return value.toString();
// }
// JavaScript: Number.MAX_SAFE_INTEGER ~ Number.MIN_SAFE_INTEGER
if (v > 9007199254740991L || v < -9007199254740991) { // 避免前端/客户端拿到精度丢失甚至严重失真的值
return value.toString();
}
return value;
}