(trunk libT) #3521 "rounding issue in tr_truncd()" -- fixed.
This commit is contained in:
parent
eb31da8fad
commit
de4ab85030
|
@ -24,7 +24,7 @@
|
|||
#include <assert.h>
|
||||
#include <ctype.h> /* isalpha(), tolower() */
|
||||
#include <errno.h>
|
||||
#include <math.h> /* pow(), fabs() */
|
||||
#include <math.h> /* pow(), fabs(), floor() */
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1386,9 +1386,7 @@ double
|
|||
tr_truncd( double x, int decimal_places )
|
||||
{
|
||||
const int i = (int) pow( 10, decimal_places );
|
||||
const double xup = x * i;
|
||||
const double x2 = (int64_t)(xup);
|
||||
return x2 / i;
|
||||
return floor( x * i ) / i;
|
||||
}
|
||||
|
||||
char*
|
||||
|
|
Loading…
Reference in New Issue