[svn-r14700] bug fix: the function equal_double that compares double type did not had nan logic for the cases of options -d and -p

tested: windows, linux
This commit is contained in:
Pedro Vicente Nunes 2008-03-04 14:38:16 -05:00
parent 78d79fa83e
commit 52378f9e94

View File

@ -119,7 +119,7 @@ static int not_comparable;
is_zero=1; \
}
# define PDIFF(a,b) ( (b>a) ? (b-a) : (a-b))
#define PDIFF(a,b) ( (b>a) ? (b-a) : (a-b))
/*-------------------------------------------------------------------------
* local prototypes
@ -127,11 +127,12 @@ static int not_comparable;
*/
static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id,hid_t region1_id, hid_t region2_id, diff_opt_t *options);
static hbool_t all_zero(const void *_mem, size_t size);
static int ull2float(unsigned long_long ull_value, float *f_value);
static hsize_t character_compare(unsigned char *mem1,unsigned char *mem2,hsize_t i,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph);
static hsize_t character_compare_opt(unsigned char *mem1,unsigned char *mem2,hsize_t i,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph);
static hbool_t equal_float(float value, float expected);
static hbool_t equal_double(double value, double expected);
static int ull2float(unsigned long_long ull_value, float *f_value);
/*-------------------------------------------------------------------------
* NaN detection
@ -693,7 +694,6 @@ hsize_t diff_datum(void *_mem1,
break;
/*-------------------------------------------------------------------------
* H5T_REFERENCE
*-------------------------------------------------------------------------
@ -2861,7 +2861,6 @@ hsize_t diff_float(unsigned char *mem1,
}
/*-------------------------------------------------------------------------
* Function: diff_double
*
@ -2891,17 +2890,31 @@ hsize_t diff_double(unsigned char *mem1,
hsize_t i;
double per;
int both_zero;
int isnan1;
int isnan2;
/* -d and !-p */
/*-------------------------------------------------------------------------
* -d and !-p
*-------------------------------------------------------------------------
*/
if (options->d && !options->p)
{
for ( i = 0; i < nelmts; i++)
{
memcpy(&temp1_double, mem1, sizeof(double));
memcpy(&temp2_double, mem2, sizeof(double));
/*-------------------------------------------------------------------------
* detect NaNs
*-------------------------------------------------------------------------
*/
isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
if ( !isnan1 && !isnan2)
{
if (ABS(temp1_double-temp2_double) > options->delta)
{
if ( print_data(options) )
@ -2912,22 +2925,35 @@ hsize_t diff_double(unsigned char *mem1,
}
nfound++;
}
} /* NaN */
mem1+=sizeof(double);
mem2+=sizeof(double);
if (options->n && nfound>=options->count)
return nfound;
}
} /* i */
}
/* !-d and -p */
/*-------------------------------------------------------------------------
* !-d and -p
*-------------------------------------------------------------------------
*/
else if (!options->d && options->p)
{
for ( i = 0; i < nelmts; i++)
{
memcpy(&temp1_double, mem1, sizeof(double));
memcpy(&temp2_double, mem2, sizeof(double));
/*-------------------------------------------------------------------------
* detect NaNs
*-------------------------------------------------------------------------
*/
isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
if ( !isnan1 && !isnan2)
{
PER(temp1_double,temp2_double);
if (not_comparable && !both_zero) /* not comparable */
@ -2957,14 +2983,18 @@ hsize_t diff_double(unsigned char *mem1,
}
nfound++;
}
} /* NaN */
mem1+=sizeof(double);
mem2+=sizeof(double);
if (options->n && nfound>=options->count)
return nfound;
}
} /* i */
}
/* -d and -p */
/*-------------------------------------------------------------------------
* -d and -p
*-------------------------------------------------------------------------
*/
else if ( options->d && options->p)
{
@ -2973,6 +3003,16 @@ hsize_t diff_double(unsigned char *mem1,
memcpy(&temp1_double, mem1, sizeof(double));
memcpy(&temp2_double, mem2, sizeof(double));
/*-------------------------------------------------------------------------
* detect NaNs
*-------------------------------------------------------------------------
*/
isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
if ( !isnan1 && !isnan2)
{
PER(temp1_double,temp2_double);
if (not_comparable && !both_zero) /* not comparable */
@ -3002,12 +3042,19 @@ hsize_t diff_double(unsigned char *mem1,
}
nfound++;
}
} /* NaN */
mem1+=sizeof(double);
mem2+=sizeof(double);
if (options->n && nfound>=options->count)
return nfound;
} /* i */
}
}
/*-------------------------------------------------------------------------
* no -d and -p
*-------------------------------------------------------------------------
*/
else
{
@ -3038,6 +3085,9 @@ hsize_t diff_double(unsigned char *mem1,
return nfound;
}
/*-------------------------------------------------------------------------
* Function: diff_schar
*