Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer logarithm of rational #18

Open
Bodigrim opened this issue Jan 6, 2019 · 1 comment
Open

Integer logarithm of rational #18

Bodigrim opened this issue Jan 6, 2019 · 1 comment

Comments

@Bodigrim
Copy link
Collaborator

Bodigrim commented Jan 6, 2019

It would be desirable to have an integer logarithm on Rational:

rationalLogBase :: Rational -> Rational -> Int
@phadej
Copy link
Collaborator

phadej commented Apr 16, 2019

This is less tricky (at least to specify), if one restricts base to > 1; even less trickier if also the n is >= 1 (but we can round towards zero) as in

Prelude> logBase 2 (4/10)
-1.3219280948873622
Prelude> logBase 2 (10/4)
1.3219280948873624
*Math.NumberTheory.Logarithms> rationalLogBase 2 (4/10)
-1
*Math.NumberTheory.Logarithms> rationalLogBase 2 (10/4)
1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants