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

Documentation about "Conversion from rational to floating-point" #56726

Closed
ArnoStrouwen opened this issue Dec 1, 2024 · 1 comment · Fixed by #56772
Closed

Documentation about "Conversion from rational to floating-point" #56726

ArnoStrouwen opened this issue Dec 1, 2024 · 1 comment · Fixed by #56772
Labels
docs This change adds or pertains to documentation maths Mathematical functions rationals The Rational type and values thereof

Comments

@ArnoStrouwen
Copy link
Contributor

The docs state:

Conversion from rational to floating-point respects the following identity for any integral values of a and b, with the exception of the two cases b == 0 and a == 0 && b < 0:

julia> a = 1; b = 2;

julia> isequal(float(a//b), a/b)
true

https://docs.julialang.org/en/v1/manual/complex-and-rational-numbers/

I do not understand the first case (b == 0), because:

julia> isequal(float(1//0),1/0)
true
julia> isequal(float(-1//0),-1/0)
true
@nsajko nsajko added docs This change adds or pertains to documentation maths Mathematical functions rationals The Rational type and values thereof labels Dec 1, 2024
@inkydragon
Copy link
Member

I think it was a mistake introduced by #45220:

-with the exception of the two cases b == 0 and a == 0 && b < 0:
+with the exception of the two cases `a==0 && b==0` and `a==0 && b < 0`.

we may add some doctests as example:

julia> a, b = 0, 0
(0, 0)

julia> float(a//b)
ERROR: ArgumentError: invalid rational: zero(Int64)//zero(Int64)
Stacktrace:
...

julia> a/b
NaN


julia> a, b = 0, -1
(0, -1)

julia> float(a//b), a/b
(0.0, -0.0)

giordano pushed a commit that referenced this issue Dec 18, 2024
Fixes #56726 added the changes that were suggested. fixing the mistake.

---------

Co-authored-by: Max Horn <[email protected]>
Co-authored-by: Chengyu Han <[email protected]>
KristofferC pushed a commit that referenced this issue Jan 2, 2025
Fixes #56726 added the changes that were suggested. fixing the mistake.

---------

Co-authored-by: Max Horn <[email protected]>
Co-authored-by: Chengyu Han <[email protected]>
(cherry picked from commit fc9e7c4)
KristofferC pushed a commit that referenced this issue Jan 2, 2025
Fixes #56726 added the changes that were suggested. fixing the mistake.

---------

Co-authored-by: Max Horn <[email protected]>
Co-authored-by: Chengyu Han <[email protected]>
(cherry picked from commit fc9e7c4)
stevengj pushed a commit that referenced this issue Jan 2, 2025
Fixes #56726 added the changes that were suggested. fixing the mistake.

---------

Co-authored-by: Max Horn <[email protected]>
Co-authored-by: Chengyu Han <[email protected]>
KristofferC pushed a commit that referenced this issue Jan 13, 2025
Fixes #56726 added the changes that were suggested. fixing the mistake.

---------

Co-authored-by: Max Horn <[email protected]>
Co-authored-by: Chengyu Han <[email protected]>
(cherry picked from commit fc9e7c4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation maths Mathematical functions rationals The Rational type and values thereof
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants