Skip to content

Commit

Permalink
Docs for RoundFromZero and some xrefs
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt authored and KristofferC committed Aug 4, 2018
1 parent e180cce commit 66c1d05
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions base/mpfr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ end
BigFloat(x, prec::Int, rounding::RoundingMode)
Create a representation of `x` as a [`BigFloat`](@ref) with precision `prec` and
rounding mode `rounding`.
[`Rounding Mode`](@ref Base.Rounding.RoundingMode) `rounding`.
"""
function BigFloat(x, prec::Int, rounding::RoundingMode)
setrounding(BigFloat, rounding) do
Expand All @@ -193,7 +193,7 @@ end
BigFloat(x, rounding::RoundingMode)
Create a representation of `x` as a [`BigFloat`](@ref) with the current global precision
and rounding mode `rounding`.
and [`Rounding Mode`](@ref Base.Rounding.RoundingMode) `rounding`.
"""
function BigFloat(x::Union{Integer, AbstractFloat, String}, rounding::RoundingMode)
BigFloat(x, precision(BigFloat), rounding)
Expand Down
18 changes: 15 additions & 3 deletions base/rounding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Currently supported rounding modes are:
- [`RoundNearestTiesAway`](@ref)
- [`RoundNearestTiesUp`](@ref)
- [`RoundToZero`](@ref)
- `RoundFromZero` ([`BigFloat`](@ref) only)
- [`RoundFromZero`](@ref) ([`BigFloat`](@ref) only)
- [`RoundUp`](@ref)
- [`RoundDown`](@ref)
"""
Expand Down Expand Up @@ -72,6 +72,18 @@ const RoundUp = RoundingMode{:Up}()
"""
const RoundDown = RoundingMode{:Down}()

"""
RoundFromZero
Rounds away from zero.
This rounding mode may only be used with `T == BigFloat` inputs to [`round`](@ref).
# Examples
```jldoctest
julia> BigFloat("1.0000000000000001", 5, RoundFromZero)
1.06
```
"""
const RoundFromZero = RoundingMode{:FromZero}() # mpfr only

"""
Expand Down Expand Up @@ -116,7 +128,7 @@ Set the rounding mode of floating point type `T`, controlling the rounding of ba
arithmetic functions ([`+`](@ref), [`-`](@ref), [`*`](@ref),
[`/`](@ref) and [`sqrt`](@ref)) and type conversion. Other numerical
functions may give incorrect or invalid values when using rounding modes other than the
default `RoundNearest`.
default [`RoundNearest`](@ref).
Note that this is currently only supported for `T == BigFloat`.
"""
Expand Down Expand Up @@ -206,7 +218,7 @@ set_zero_subnormals(yes::Bool) = ccall(:jl_set_zero_subnormals,Int32,(Int8,),yes
"""
get_zero_subnormals() -> Bool
Returns `false` if operations on subnormal floating-point values ("denormals") obey rules
Return `false` if operations on subnormal floating-point values ("denormals") obey rules
for IEEE arithmetic, and `true` if they might be converted to zeros.
"""
get_zero_subnormals() = ccall(:jl_get_zero_subnormals,Int32,())!=0
Expand Down
1 change: 1 addition & 0 deletions doc/src/base/math.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Base.Rounding.RoundNearest
Base.Rounding.RoundNearestTiesAway
Base.Rounding.RoundNearestTiesUp
Base.Rounding.RoundToZero
Base.Rounding.RoundFromZero
Base.Rounding.RoundUp
Base.Rounding.RoundDown
Base.round(::Complex{<: AbstractFloat}, ::RoundingMode, ::RoundingMode)
Expand Down

0 comments on commit 66c1d05

Please sign in to comment.