Skip to content

Commit

Permalink
complex numbers should be given equal place in Julia (#46476)
Browse files Browse the repository at this point in the history
  • Loading branch information
udohjeremiah authored Aug 31, 2022
1 parent 8fa066b commit 1ece3f6
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions base/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1067,18 +1067,32 @@ end
#Requires two different RoundingModes for the real and imaginary components
"""
round(z::Complex[, RoundingModeReal, [RoundingModeImaginary]])
round(z::Complex[, RoundingModeReal, [RoundingModeImaginary]]; digits=, base=10)
round(z::Complex[, RoundingModeReal, [RoundingModeImaginary]]; sigdigits=, base=10)
round(z::Complex[, RoundingModeReal, [RoundingModeImaginary]]; digits=0, base=10)
round(z::Complex[, RoundingModeReal, [RoundingModeImaginary]]; sigdigits, base=10)
Return the nearest integral value of the same type as the complex-valued `z` to `z`,
breaking ties using the specified [`RoundingMode`](@ref)s. The first
[`RoundingMode`](@ref) is used for rounding the real components while the
second is used for rounding the imaginary components.
`RoundingModeReal` and `RoundingModeImaginary` default to [`RoundNearest`](@ref),
which rounds to the nearest integer, with ties (fractional values of 0.5)
being rounded to the nearest even integer.
# Example
```jldoctest
julia> round(3.14 + 4.5im)
3.0 + 4.0im
julia> round(3.14 + 4.5im, RoundUp, RoundNearestTiesUp)
4.0 + 5.0im
julia> round(3.14159 + 4.512im; digits = 1)
3.1 + 4.5im
julia> round(3.14159 + 4.512im; sigdigits = 3)
3.14 + 4.51im
```
"""
function round(z::Complex, rr::RoundingMode=RoundNearest, ri::RoundingMode=rr; kwargs...)
Expand Down

0 comments on commit 1ece3f6

Please sign in to comment.