Skip to content

Commit

Permalink
Update complex-and-rational-numbers.md
Browse files Browse the repository at this point in the history
fixes rational docs
  • Loading branch information
Priynsh authored Dec 7, 2024
1 parent 3a68b03 commit 79b5274
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion doc/src/manual/complex-and-rational-numbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,29 @@ julia> float(3//4)
```

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`:
of `a` and `b`, with the exception of the two cases `a==0 && b==0` and `a==0 && b < 0`:

```jldoctest
julia> a = 1; b = 2;
julia> isequal(float(a//b), a/b)
true
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)
```

Constructing infinite rational values is acceptable:
Expand Down

0 comments on commit 79b5274

Please sign in to comment.