Giter Club home page Giter Club logo

Comments (3)

mateusneresrb avatar mateusneresrb commented on August 16, 2024

It ends up in the Double.parseDouble of this class and removes the 0. The correct thing to do would be to return a BigDecimal, but this scenario only occurs with a string longer than 18 characters.

protected Number extractFloat() throws ParseException {
if (!acceptLeadinZero)
checkLeadinZero();
try {
if (!useHiPrecisionFloat)
return Float.parseFloat(xs);
// follow JSonIJ parsing method
if (xs.length() > 18) {
// use extra CPU to check if the result can be return as double without
// precision lost
if (!unrestictBigDigit) {
double asDouble = Double.parseDouble(xs);
final String doubleStr = String.valueOf(asDouble);
// we need a compare `e` `E` `e+` `E+`
if (compareDoublePrecision(doubleStr, xs)) {
return asDouble;
}
}
return new BigDecimal(xs);
}
return Double.parseDouble(xs);
} catch (NumberFormatException e) {
throw new ParseException(pos, ERROR_UNEXPECTED_TOKEN, xs);
}
}

from json-smart-v2.

UrielCh avatar UrielCh commented on August 16, 2024

10.50 and 10.5 are the same value.
fill free to re-format flot number to keep extra tailling zero, or store you digits as string.

from json-smart-v2.

mateusneresrb avatar mateusneresrb commented on August 16, 2024

10,50 e 10,5 são o mesmo valor. preencha livre para reformatar o número do flot para manter o zero de rejeitos extras ou armazene seus dígitos como string.

I see, they're the same value, but after I turn it into a bigdecimal, because I need the 0, it ends up removing it. One option would be to use a custom mapper?

from json-smart-v2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.