Factorize denominator of rationale

Paul Zimmermann Paul.Zimmermann at inria.fr
Tue Nov 22 18:45:02 CET 2022


the function you want is probably mpz_remove().
(A _ui version would be most welcome.)

Best regards,
Paul Zimmermann

> From: Øystein Schønning-Johansen <oysteijo at gmail.com>
> Date: Tue, 22 Nov 2022 11:00:50 +0100
> Hi!
> I'm working with probabilities of a sequence of dice rolls, and the
> different probabilities to be exact with rationales. I've got it all
> working fine.
> However, I want to write out all probabilities to a file and since there's
> a lot of them, I want to reduce the file size and need the output string to
> be as short as possible. I hence use mpq_canonicalize() and write out with
> base 36. Works, but can I even be better?
> Since these are consecutive dice rolls, I can always represent the
> denominator (after canonicalize) as (2^a)*(3^b) and I then only have to
> store the a and the b. So, the question is: How can I find the a and the b
> of such denominators?
> Best regards,
> -Øystein
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at gmplib.org
> https://gmplib.org/mailman/listinfo/gmp-discuss

More information about the gmp-discuss mailing list