Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add Base.hastypemax method #42

Merged
merged 2 commits into from
Sep 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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