Change ParserBase to track floats independently from doubles
See original GitHub issueIt seems like in some cases, casting a double to a float may result in a slightly different answer than parsing the original number string using Float.parseFloat.
This code in ParserBase (jackson-core) may be contributing to an issue that @plokhotnyuk described with parsing 1.199999988079071 as a float.
@Override
public float getFloatValue() throws IOException
{
double value = getDoubleValue();
/* 22-Jan-2009, tatu: Bounds/range checks would be tricky
* here, so let's not bother even trying...
*/
/*
if (value < -Float.MAX_VALUE || value > MAX_FLOAT_D) {
_reportError("Numeric value ("+getText()+") out of range of Java float");
}
*/
return (float) value;
}
From my testing, it seems that casting doubles to floats may not get the same result as parsing the text representation directly with Float.parseFloat(String).
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
ParserBase (Jackson-core 2.12.0 API) - FasterXML
Intermediate base class used by all Jackson JsonParser implementations. Contains most common things that are independent of actual underlying input source.
Read more >Replace all floats with doubles - java - Stack Overflow
Is it possible to use some construct to replace all floats with doubles (or the opposite) without refactoring?
Read more >IO tools (text, CSV, HDF5, …) — pandas 1.5.2 documentation
Specifies which converter the C engine should use for floating-point values. The options are None for the ordinary converter, high for the high-precision ......
Read more >Changelog — Python 3.11.1 documentation
__set_format__() method to float.__setformat__() to fix a typo introduced in Python 3.7. The method is only used by test_float. Patch by Victor Stinner....
Read more >XC16 and printf of floats and doubles << SOLVED >>
Thanks for the suggestion. I had already tried casting the variables to double without success. I tried, as you suggested, changing the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@cowtowncoder I added https://github.com/FasterXML/jackson-databind/pull/3470 - it shows the issue that @plokhotnyuk reported. Would you be able to take a look?
I think this was indeed resolved via #757, closing.