When saving XMLs, don't round floats that are bigger than INT_MAX. Fixes #1278
PiperOrigin-RevId: 590692020 Change-Id: Icd11d20f47bc4163eb4378f4cb031b8fd9d13612
This commit is contained in:
committed by
Copybara-Service
parent
0d37670698
commit
5b2c98f8f1
+3
-1
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
@@ -1004,7 +1005,8 @@ void mjXUtil::WriteAttr(XMLElement* elem, string name, int n, const T* data, con
|
||||
}
|
||||
|
||||
// append number
|
||||
if (isint(data[i])) {
|
||||
double doubledata = static_cast<double>(data[i]);
|
||||
if (doubledata < INT_MAX && doubledata > -INT_MAX && isint(data[i])) {
|
||||
stream << Round(data[i]);
|
||||
} else {
|
||||
stream << data[i];
|
||||
|
||||
Reference in New Issue
Block a user