From: Han-Wen Nienhuys Date: Sun, 27 Jul 2003 16:48:16 +0000 (+0000) Subject: (my_round): ANSI-C compatible rounding. X-Git-Tag: release/1.7.30~57 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f06ea0716df6143c10f68b6c66f4597a931eb0a4;p=lilypond.git (my_round): ANSI-C compatible rounding. --- diff --git a/ChangeLog b/ChangeLog index 175c51cee1..1a27d11961 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003-07-27 Han-Wen Nienhuys + + * flower/libc-extension.cc (my_round): ANSI-C compatible rounding. + 2003-07-27 Rune Zedeler * Documentation/user/refman.itely (Percussion): Small diff --git a/flower/include/libc-extension.hh b/flower/include/libc-extension.hh index fc53e3c81c..4040543768 100644 --- a/flower/include/libc-extension.hh +++ b/flower/include/libc-extension.hh @@ -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 diff --git a/flower/libc-extension.cc b/flower/libc-extension.cc index 4d42ce44b3..35484e3b57 100644 --- a/flower/libc-extension.cc +++ b/flower/libc-extension.cc @@ -8,6 +8,8 @@ Jan Nieuwenhuizen */ +#include + #include #include #include @@ -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 diff --git a/lily/staff-symbol-referencer.cc b/lily/staff-symbol-referencer.cc index e16a7ead07..dec5000b2a 100644 --- a/lily/staff-symbol-referencer.cc +++ b/lily/staff-symbol-referencer.cc @@ -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); }