begriffs / pg_rational

Precise fractional arithmetic for PostgreSQL
MIT License
238 stars 14 forks source link

Question: Why using while loop in intermediate? #22

Closed yosshi4486 closed 3 years ago

yosshi4486 commented 3 years ago

Hello! I'm developer developing swift version of pgrational for storing user defined order in DB.

Can I ask a question?

I want to know the reason why while loop is used in intermediate? I think executing mediant(&x, &y, med) once is much faster than mediant(&lo, &hi, med) with loop. I suppose that there are some mathematical reasons or technical purposes to do so.

https://github.com/begriffs/pg_rational/blob/70c4decc03773c86ffdda829e39ef39011cc205e/pg_rational.c#L380-L389