From 524830d67eb640e75d2dbaf85e3e863ff9643564 Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Wed, 12 Jan 2005 15:40:36 -0500 Subject: [svn-r9814] Purpose: Bug fix Description: the last 2 bytes of mantissa can be lost when converting from unsigned long long to long double. In last check-in, a fix was made to ignore that precision loss. But sometimes, the last 2 bytes are rounded up to the 3rd last byte. Solution: Ignore the 3rd last byte, too, when comparing values. Platforms tested: sleipnir - only this system is concerned. --- test/dtypes.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/dtypes.c b/test/dtypes.c index c6d6a57..684ed19 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -5851,7 +5851,8 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst) /* For GNU compilers on FreeBSD(sleipnir), during conversion from 'unsigned long long' * to 'long double', the last 2 bytes of mantissa are lost. But this loss seems - * acceptable. We allow it go through instead of fail it. + * acceptable. We allow it to go through instead of fail it. Sometimes, there's roundup + * to the 3rd last byte of mantissa. So we only try to compare all but the last 3 bytes. */ #ifndef H5_ULLONG_TO_LDOUBLE_PRECISION_WORKS if(src_type==INT_ULLONG && dst_type==FLT_LDOUBLE) { @@ -5859,7 +5860,7 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst) HDmemcpy(&tmp_s,&buf[j*dst_size],sizeof(long double)); HDmemcpy(&tmp_h,&hw[0],sizeof(long double)); /*Don't compare the last 2 bytes of mantissa*/ - if(!HDmemcmp(&tmp_s+2, &tmp_h+2, sizeof(long double)-2)) + if(!HDmemcmp(&tmp_s+3, &tmp_h+3, sizeof(long double)-3)) continue; /*no error*/ } #endif /*end H5_ULLONG_TO_LDOUBLE_PRECISION_WORKS*/ -- cgit v0.12