diff options
author | Thomas White <taw@bitwiz.org.uk> | 2010-09-18 23:05:56 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:26:58 +0100 |
commit | 067f84342e356cab6a64630ddd3c234ba6ac603d (patch) | |
tree | e1d2371251ab9d420964360b2fc4e6497cb4854f /src | |
parent | 0562a85a1314b3d096928a31505e8d74f746146d (diff) |
Set rounding mode, use lrint() instead of rint()
Diffstat (limited to 'src')
-rw-r--r-- | src/cubeit.c | 9 | ||||
-rw-r--r-- | src/peaks.c | 8 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/cubeit.c b/src/cubeit.c index 41f4811f..22757303 100644 --- a/src/cubeit.c +++ b/src/cubeit.c @@ -24,6 +24,7 @@ #include <sys/time.h> #include <assert.h> #include <png.h> +#include <fenv.h> #include "utils.h" #include "hdf5-file.h" @@ -187,6 +188,7 @@ static void process_image(struct process_args *pargs) cell_get_cartesian(pargs->cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz); + fesetround(1); /* Round towards nearest */ for ( x=0; x<image.width; x++ ) { for ( y=0; y<image.height; y++ ) { @@ -202,10 +204,11 @@ static void process_image(struct process_args *pargs) kd = q.u * bx + q.v * by + q.w * bz; ld = q.u * cx + q.v * cy + q.w * cz; - h = (signed int)rint(hd); - k = (signed int)rint(kd); - l = (signed int)rint(ld); + h = lrint(hd); + k = lrint(kd); + l = lrint(ld); + /* FIXME: This is really, really slow */ get_asymm(h, k, l, &ha, &ka, &la, pargs->sym); if ( (ha!=pargs->ht) || (ka!=pargs->kt) || (la!=pargs->lt) ) { continue; diff --git a/src/peaks.c b/src/peaks.c index 229037f7..fdf5b961 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -21,6 +21,7 @@ #include <assert.h> #include <gsl/gsl_statistics_int.h> #include <pthread.h> +#include <fenv.h> #include "image.h" #include "utils.h" @@ -464,6 +465,7 @@ int find_projected_peaks(struct image *image, UnitCell *cell) cell_get_cartesian(cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz); + fesetround(1); /* Round towards nearest */ for ( x=0; x<image->width; x++ ) { for ( y=0; y<image->height; y++ ) { @@ -481,9 +483,9 @@ int find_projected_peaks(struct image *image, UnitCell *cell) kd = q.u * bx + q.v * by + q.w * bz; ld = q.u * cx + q.v * cy + q.w * cz; - h = (signed int)rint(hd); - k = (signed int)rint(kd); - l = (signed int)rint(ld); + h = lrint(hd); + k = lrint(kd); + l = lrint(ld); dh = hd - h; dk = kd - k; |