mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
LibPDF: Parse integer numbers with atoi() instead of strtof()
strtof() produces rounding errors for very large numbers, which we don't want for integers, as they may have to be precise.
This commit is contained in:
parent
c2ad29c85f
commit
0bc3333740
1 changed files with 2 additions and 4 deletions
|
@ -194,12 +194,10 @@ PDFErrorOr<Value> Parser::parse_number()
|
|||
m_reader.consume_whitespace();
|
||||
|
||||
auto string = String(m_reader.bytes().slice(start_offset, m_reader.offset() - start_offset));
|
||||
float f = strtof(string.characters(), nullptr);
|
||||
if (is_float)
|
||||
return Value(f);
|
||||
return Value(strtof(string.characters(), nullptr));
|
||||
|
||||
VERIFY(floorf(f) == f);
|
||||
return Value(static_cast<int>(f));
|
||||
return Value(atoi(string.characters()));
|
||||
}
|
||||
|
||||
PDFErrorOr<NonnullRefPtr<NameObject>> Parser::parse_name()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue