diff options
author | Robb Matzke <matzke@llnl.gov> | 2001-02-03 04:38:09 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 2001-02-03 04:38:09 (GMT) |
commit | 5fa7f93263e18ec0bf63c0d4cff5ba310c768205 (patch) | |
tree | ea844213e33383f9acb73b566053deded82e4f54 /src | |
parent | 500e15e77ee2655efffb9a7abcbffe2df4a2cc41 (diff) | |
download | hdf5-5fa7f93263e18ec0bf63c0d4cff5ba310c768205.zip hdf5-5fa7f93263e18ec0bf63c0d4cff5ba310c768205.tar.gz hdf5-5fa7f93263e18ec0bf63c0d4cff5ba310c768205.tar.bz2 |
[svn-r3346] ./hdf5-1.4/src/H5Tconv.c
2001-02-03 00:19:25 Robb Matzke <matzke@llnl.gov>
* H5T_conv_f_f: Fixed a bug where I had forgotten to increment the floating-point
exponent if rounding the significand resulted in a
carry. Thanks to Guillaume Colin de Verdiere for
finding this one!
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Tconv.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 973782a..b9b90e9 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -2523,6 +2523,11 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, * then convert one value at each memory location advancing * BUF_STRIDE bytes each time; otherwise assume both source and * destination values are packed. + * + * Robb Matzke, 2001-02-02 + * Oops, forgot to increment the exponent when rounding the + * significand resulted in a carry. Thanks to Guillaume Colin + * de Verdiere for finding this one! *------------------------------------------------------------------------- */ herr_t @@ -2852,6 +2857,37 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, } /* Write the exponent */ + if (carry) { + expo++; + if (expo>=expo_max) { + /* + * The exponent is too large to fit in the available + * region or it results in the maximum possible value. + * Use positive or negative infinity instead unless the + * application specifies something else. Before + * calling the overflow handler make sure the source + * buffer we hand it is in the original byte order. + */ + if (H5T_overflow_g) { + uint8_t over_src[256]; + assert(src_p->size<=sizeof over_src); + if (H5T_ORDER_BE==src.order) { + for (i=0; i<src_p->size; i++) { + over_src[src_p->size-(i+1)] = s[i]; + } + } else { + for (i=0; i<src_p->size; i++) { + over_src[i] = s[i]; + } + } + if ((H5T_overflow_g)(src_id, dst_id, over_src, d)>=0) { + goto next; + } + } + expo = expo_max; + H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); + } + } H5_CHECK_OVERFLOW(expo,hssize_t,hsize_t); H5T_bit_set_d(d, dst.u.f.epos, dst.u.f.esize, (hsize_t)expo); |