summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2011-01-13 18:13:39 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2011-01-13 18:13:39 +0000
commitd86225e0ff1e950fc69cb32fb536878ed1cd7374 (patch)
tree57fb0cf4f9092039f94391598e4399eb17dbf7c5 /src
parent6466f10447e0ad771452fc88b26e0df2b630a01e (diff)
downloadmpfr-d86225e0ff1e950fc69cb32fb536878ed1cd7374.tar.gz
[out_raw.c] first proposal for external format
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@7336 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src')
-rw-r--r--src/out_raw.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/out_raw.c b/src/out_raw.c
new file mode 100644
index 000000000..446074971
--- /dev/null
+++ b/src/out_raw.c
@@ -0,0 +1,40 @@
+/* format for out_raw:
+ A mpfr_t is represented by up to 3 fields, each one is represented by a
+ sequence of 32-bit words. 32-bit words are stored as 4 bytes in little
+ endian format:
+ (a) a field for sign, precision and other bit-fields:
+ - the sign (1 bit)
+ - 2 bits for NaN, Inf, 0, normal numbers:
+ 00: 0
+ 01: normal
+ 10: Inf
+ 11: NaN
+ - 1 bit for the precision encoding (prec_enc)
+ - 1 bit for the exponent encoding (exp_enc) for normal numbers,
+ otherwise 0 is stored here (reserved for future extensions)
+ If prec_enc=0, the remaining 27 bits encode the precision (< 2^27)
+ If prec_enc=1, the precision is stored in the following 27 bits
+ (high part) and then 32 bits (low part). Thus the maximal precision
+ is 59 bits.
+ (b) (optional) a field for the exponent:
+ - if the number is NaN, Inf, 0, this field is empty
+ - if exp_enc=0, this field contains one 32-bit (signed) word encoding
+ the exponent
+ - if exp_enc=1, a first 32-bit word encodes a positive integer m,
+ and the following m 32-bit words encode the exponent (in 2-complement
+ representation, with least significant words first)
+ (c) (optional) a field for the significand:
+ - if the number is NaN, Inf, 0, this field is empty
+ - otherwise, let p = ceil(prec/32), the significand is represented
+ by p consecutive 32-bit words (least significant words first).
+ Thus on a little-endian machine the significand can be directly
+ copied using memcopy.
+ Examples:
+ - a normal binary32 IEEE-754 number uses 96 bits: 32 for (a), 32 for (b),
+ and 32 for (c);
+ - a normal binary64 IEEE-754 number uses 128 bits: 32 for (a), 32 for (b),
+ and 64 for (c) (idem for a significand of 64 bits, as in Intel x86
+ double-extended format);
+ - a normal binary128 IEEE-754 number uses 192 bits: 32 for (a), 32 for (b),
+ and 128 for (c).
+ */