]> git.donarmstrong.com Git - lilypond.git/commitdiff
(my_round): ANSI-C compatible rounding.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 27 Jul 2003 16:48:16 +0000 (16:48 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 27 Jul 2003 16:48:16 +0000 (16:48 +0000)
ChangeLog
flower/include/libc-extension.hh
flower/libc-extension.cc
lily/staff-symbol-referencer.cc

index 175c51cee155bec7d5cc3cefe213f302906b52dd..1a27d1196160f96c0e9c199a6be0f5d5a2186510 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2003-07-27  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+
+       * flower/libc-extension.cc (my_round): ANSI-C compatible rounding.
+
 2003-07-27  Rune Zedeler  <rz@daimi.au.dk>
 
        * Documentation/user/refman.itely (Percussion): Small
index fc53e3c81c6b3875915fc951329f3864d31d8555..4040543768f1dd08b8a477df860b1ff79945fc2e 100644 (file)
@@ -49,4 +49,6 @@ Byte *memrchr (Byte const * p, int n, char c);
 Byte *strrev (Byte* byte, int length_i);
 
 
+double my_round (double);
+
 #endif // LIBC_EXTENSION_HH
index 4d42ce44b3940f661257abdb5ca9521695847e24..35484e3b570c8d1248d8d7a9bf5e125eb93c9332 100644 (file)
@@ -8,6 +8,8 @@
          Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
+#include <math.h>
+
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
@@ -35,6 +37,14 @@ strnupr (char* start, int n)
   return start;
 }
 
+/*
+  There are some strange problems with round() on early glibcs.
+ */
+double
+my_round (double x)
+{
+  return  floor (x -0.5)+ 1.0 ;
+}
 
 
 #if !HAVE_ISINF
index e16a7ead078bbb206372b398784356b470ee5490..dec5000b2a944e299345ba9c74321544de2bfeff 100644 (file)
@@ -86,10 +86,7 @@ LY_DEFINE(ly_grob_staff_position,
   Real pos = Staff_symbol_referencer::get_position (g);
 
   if (fabs (rint (pos) -pos) < 1e-6) // ugh.
-    /*
-      lrint has issues with various glibcs. 
-     */
-    return gh_int2scm ((int) round (pos));
+    return gh_int2scm ((int) my_round (pos));
   else
     return gh_double2scm (pos);
 }