aboutsummaryrefslogtreecommitdiff
path: root/src/cubeit.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/cubeit.c
parent0562a85a1314b3d096928a31505e8d74f746146d (diff)
Set rounding mode, use lrint() instead of rint()
Diffstat (limited to 'src/cubeit.c')
-rw-r--r--src/cubeit.c9
1 files changed, 6 insertions, 3 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;