Skip to content

Commit

Permalink
consistency on typemax and typemin docs (JuliaLang#46827)
Browse files Browse the repository at this point in the history
* consistency on typemax and typemin docs

The `typemax` and `typemin` docs isn't consistent with each other on its examples and `see also` section (see reasons below).

While this isn't an issue when looking up the function with `help>` to work with integers, for floating-point types, its a big deal because:
- On the `typemax` examples, there is a very good example there with a great comment, pointing users on to look into `floatmax`, if `typemax` doesn't serves them; but the `typemin` doesn't have this - which isn't great, since both `typemax` and `typemin` have great use.
- The `see also` section on `typemax` point users to other available functions which might prove or introduce other points to consider if `typemax` isn't what they're looking for; for `typemin`, this isn't present.

I provided examples on integers, just so the function isn't thought of like working for only floating points.

Moreover, I feel like the current docs were written assuming users would always lookup `typemin` and `typemax` in `help>`, before using anyone of them. Most time this is true, but I think it's best not to assume.
  • Loading branch information
udohjeremiah authored Sep 21, 2022
1 parent 67f994c commit ffa76f9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion base/int.jl
Original file line number Diff line number Diff line change
Expand Up @@ -772,13 +772,24 @@ promote_rule(::Type{UInt128}, ::Type{Int128}) = UInt128
The lowest value representable by the given (real) numeric DataType `T`.
See also: [`floatmin`](@ref), [`typemax`](@ref), [`eps`](@ref).
# Examples
```jldoctest
julia> typemin(Int8)
-128
julia> typemin(UInt32)
0x00000000
julia> typemin(Float16)
-Inf16
julia> typemin(Float32)
-Inf32
julia> nextfloat(-Inf32) # smallest finite Float32 floating point number
-3.4028235f38
```
"""
function typemin end
Expand All @@ -801,7 +812,10 @@ julia> typemax(UInt32)
julia> typemax(Float64)
Inf
julia> floatmax(Float32) # largest finite floating point number
julia> typemax(Float32)
Inf32
julia> floatmax(Float32) # largest finite Float32 floating point number
3.4028235f38
```
"""
Expand Down

0 comments on commit ffa76f9

Please sign in to comment.