aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cubeit.c9
-rw-r--r--src/peaks.c8
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;