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: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to