mirror of
git://git.psyced.org/git/psyced
synced 2024-08-15 03:25:10 +00:00
float would only last for one more year.. we have to use strings for
bignum action
This commit is contained in:
parent
b22f2e8b9b
commit
e1da3b144b
2 changed files with 27 additions and 13 deletions
|
@ -527,9 +527,7 @@ PROTECTED mixed nextObject() {
|
|||
if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+') {
|
||||
int a; float b_; string c_;
|
||||
sscanf(s, "%d%s", a, c_);
|
||||
// some values of json ints exceed the limits of MAX_INT, in that case we need to use float -lynX
|
||||
// maybe it is more efficient, if we used float in all cases then
|
||||
if ((c_ && sizeof(c_)) || (a && s != to_string(a))) {
|
||||
if ((c_ && sizeof(c_))) {
|
||||
#ifdef __PIKE__
|
||||
sscanf(s, "%f", b_);
|
||||
#else
|
||||
|
@ -537,6 +535,18 @@ PROTECTED mixed nextObject() {
|
|||
#endif
|
||||
return b_;
|
||||
}
|
||||
if (!a || s != to_string(a)) {
|
||||
// some values of json ints exceed the limits of MAX_INT.
|
||||
// in that case we tried to use float, but rendering floats
|
||||
// will produce something like 2.17734e+09 instead of just
|
||||
// a long integer. we have to return a string here, and risk
|
||||
// to run into runtime errors. we should probably stop trying
|
||||
// to convert json integers into ints in the first place.
|
||||
// javascript and lpc just aren't compatible. do we have a
|
||||
// bignum package for ldmud?
|
||||
P3(("Warning: JSON integer too big. Returning %O as string.\n", s))
|
||||
return s;
|
||||
}
|
||||
else return a;
|
||||
}
|
||||
if (s == "") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue