aboutsummaryrefslogtreecommitdiff
path: root/src/peaks.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2010-09-18 23:05:56 +0200
committerThomas White <taw@physics.org>2012-02-22 15:26:58 +0100
commit067f84342e356cab6a64630ddd3c234ba6ac603d (patch)
treee1d2371251ab9d420964360b2fc4e6497cb4854f /src/peaks.c
parent0562a85a1314b3d096928a31505e8d74f746146d (diff)
Set rounding mode, use lrint() instead of rint()
Diffstat (limited to 'src/peaks.c')
-rw-r--r--src/peaks.c8
1 files changed, 5 insertions, 3 deletions
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;