Jean Abou Samra <j...@abou-samra.fr> writes: > Le 04/06/2022 à 13:16, Luca Fascione a écrit : >> On Sat, Jun 4, 2022 at 12:47 PM David Kastrup <d...@gnu.org> wrote: >> >>> LilyPond uses precise arithmetic. >>> >> Thanks David, just out of curiosity, where's a reference to the specific >> implementation we're using? > > > > C++ code uses the Rational type, which is implemented in > flower/rational.cc and flower/include/rational.hh. Scheme > code uses plain Guile numbers. Scheme mixes "exact" (rational) > and "inexact" (floating-point) numbers in a very lax way. > This is documented at > > https://www.gnu.org/software/guile/manual/html_node/Reals-and-Rationals.html > > The conversion between the two is in lily/lily-guile.cc > ({from,to,is}_scm<Rational>). > > The Moment type is defined in lily/moment.cc and lily/include/moment.hh. > It has two Rational members, a main part and a grace part. > > >> Further, besides the floating point math segment, does the rest feel like >> it's on target to you? > > > Honestly, I feel like we're making a big deal of something > that doesn't have a lot of practical ramifications for LilyPond.
git grep 'ly:moment-\(add\|sub\|mul\|div\|mod\)' puts out a good page or so, much of it in articulate.ly and swing.ly. Admittedly, both of those files are of the kind we would want to encourage people to write, and that kind of change makes it more convenient. But indeed, in the overall code base very little would change and one would want to carefully check the effect on performance (having the generic `+` support more types will affect performance _outside_ of actual uses with the Moment type, and it depends on GOOPS' implementation just how much: this is supposed to be quite less expensive with Guile 2 than it was with Guile 1, but I don't know just how much so). -- David Kastrup