Skip to content

Commit

Permalink
Add Base.hastypemax method (#42)
Browse files Browse the repository at this point in the history
* Add Base.hastypemax method

* Add changelog item
  • Loading branch information
sostock authored Sep 18, 2021
1 parent b3c9e78 commit 2296f9d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## master

* ![Bugfix](https://img.shields.io/badge/-bugfix-purple) Added specialized `Base.hastypemax` method because the generic fallback doesn’t work correctly for `BigHalfInt`. ([#42](https://github.com/sostock/HalfIntegers.jl/pull/42))

## v1.4.1

* ![Maintenance](https://img.shields.io/badge/-maintenance-grey) Compatibility with SaferIntegers v3. ([#40](https://github.com/sostock/HalfIntegers.jl/pull/40))
Expand Down
1 change: 1 addition & 0 deletions src/HalfIntegers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ function Base.tryparse(::Type{Half{T}}, s::AbstractString) where T<:Integer
return isempty(matched.captures[2]) ? Half{T}(num) : half(num)
end

Base.hastypemax(::Type{Half{T}}) where T<:Integer = Base.hastypemax(T)
Base.typemax(::Type{Half{T}}) where T<:Integer = half(typemax(T))
Base.typemin(::Type{Half{T}}) where T<:Integer = half(typemin(T))

Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,9 @@ end
for T in (inttypes..., uinttypes...)
@eval @test typemin(Half{$T}) === half(Half{$T}, typemin($T))
@eval @test typemax(Half{$T}) === half(Half{$T}, typemax($T))
@eval @test Base.hastypemax(Half{$T})
end
@test !Base.hastypemax(BigHalfInt)
end

@testset "one/zero/isone/iszero" begin
Expand Down

0 comments on commit 2296f9d

Please # to comment.