Factorize denominator of rationale

Paul Leyland paul.leyland at gmail.com
Tue Nov 29 17:03:20 CET 2022


By far the cheapest in terms of human effort would be to leave your code 
alone and pipe its output through gz(1) or the like. It could well be 
computationally less expensive too if you have to implement a fancy 
condensed representation.

Is space really that expensive for you?


Paul

On 22/11/2022 10:00, Øystein Schønning-Johansen wrote:
> 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