diff options
author | Neil Booth <neil@daikokuya.co.uk> | 2007-10-12 16:02:31 +0000 |
---|---|---|
committer | Neil Booth <neil@daikokuya.co.uk> | 2007-10-12 16:02:31 +0000 |
commit | 1171ddfc5ffa4cca34b45b49dd714040bb8ef4d3 (patch) | |
tree | 2f840ee6100a4c32750767d1c68b14b8821ae91a /include/llvm/ADT/APFloat.h | |
parent | fd7bb6cdaf44bdbc8a75821a9058bf15ec84abc4 (diff) | |
download | external_llvm-1171ddfc5ffa4cca34b45b49dd714040bb8ef4d3.zip external_llvm-1171ddfc5ffa4cca34b45b49dd714040bb8ef4d3.tar.gz external_llvm-1171ddfc5ffa4cca34b45b49dd714040bb8ef4d3.tar.bz2 |
Implement correctly-rounded decimal->binary conversion, i.e. conversion
from user input strings.
Such conversions are more intricate and subtle than they may appear;
it is unlikely I have got it completely right first time. I would
appreciate being informed of any bugs and incorrect roundings you
might discover.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42912 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/APFloat.h')
-rw-r--r-- | include/llvm/ADT/APFloat.h | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/include/llvm/ADT/APFloat.h b/include/llvm/ADT/APFloat.h index 38d110d..7a43843 100644 --- a/include/llvm/ADT/APFloat.h +++ b/include/llvm/ADT/APFloat.h @@ -60,7 +60,10 @@ if the requested precision is less than the natural precision the output is correctly rounded for the specified rounding mode. - Conversion to and from decimal text is not currently implemented. + It also reads decimal floating point numbers and correctly rounds + according to the specified rounding mode. + + Conversion to decimal text is not currently implemented. Non-zero finite numbers are represented internally as a sign bit, a 16-bit signed exponent, and the significand as an array of @@ -83,13 +86,12 @@ Some features that may or may not be worth adding: - Conversions to and from decimal strings (hard). + Binary to decimal conversion (hard). Optional ability to detect underflow tininess before rounding. New formats: x87 in single and double precision mode (IEEE apart - from extended exponent range) and IBM two-double extended - precision (hard). + from extended exponent range) (hard). New operations: sqrt, IEEE remainder, C90 fmod, nextafter, nexttoward. @@ -186,10 +188,12 @@ namespace llvm { opStatus multiply(const APFloat &, roundingMode); opStatus divide(const APFloat &, roundingMode); opStatus mod(const APFloat &, roundingMode); - void copySign(const APFloat &); opStatus fusedMultiplyAdd(const APFloat &, const APFloat &, roundingMode); - void changeSign(); // neg - void clearSign(); // abs + + /* Sign operations. */ + void changeSign(); + void clearSign(); + void copySign(const APFloat &); /* Conversions. */ opStatus convert(const fltSemantics &, roundingMode); @@ -272,8 +276,12 @@ namespace llvm { opStatus convertFromUnsignedParts(const integerPart *, unsigned int, roundingMode); opStatus convertFromHexadecimalString(const char *, roundingMode); + opStatus convertFromDecimalString (const char *, roundingMode); char *convertNormalToHexString(char *, unsigned int, bool, roundingMode) const; + opStatus roundSignificandWithExponent(const integerPart *, unsigned int, + int, roundingMode); + APInt convertFloatAPFloatToAPInt() const; APInt convertDoubleAPFloatToAPInt() const; APInt convertF80LongDoubleAPFloatToAPInt() const; |