[LLVMbugs] [Bug 11086] New: APFloat::toString is wrong in specific cases
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Oct 7 13:20:08 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=11086
Summary: APFloat::toString is wrong in specific cases
Product: libraries
Version: 2.9
Platform: PC
OS/Version: other
Status: NEW
Severity: normal
Priority: P
Component: Core LLVM classes
AssignedTo: unassignedbugs at nondot.org
ReportedBy: jerome_123 at hotmail.com
CC: llvmbugs at cs.uiuc.edu
Repro:
llvm::SmallVectorImpl<char> buffer(0);
llvm::APFloat apFloat( 29.999998 );
apFloat.toString( buffer, 6 );
Output:
0.485211
I fixed it by replacing, in APFloat.cpp,
unsigned precision = semantics->precision + 137 * texp / 59;
by
unsigned precision = semantics->precision + 137 * texp / 59 + 1;
I think that the current formula didn't take into account the fact that ints
are rounding down, which led to too small precisions in exceptional cases like
this.
(OS = Windows 7; you don't have that in your OS list??)
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list