Skip to content
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
1 change: 1 addition & 0 deletions src/normed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function _convert(::Type{N}, x::Tf) where {T, f, N <: Normed{T,f}, Tf <: Union{F
0 <= x <= Tf((typemax(T)-rawone(N))/rawone(N)+1) || throw_converterror(N, x)
end

f == 1 && x == Tf(typemax(N)) && return typemax(N)
if f <= (significand_bits(Tf) + 1) && bitwidth(T) < significand_bits(Tf)
return reinterpret(N, unsafe_trunc(T, round(rawone(N) * x)))
end
Expand Down
3 changes: 2 additions & 1 deletion test/normed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ end
if isinf(input_typemax)
@test reinterpret(N(floatmax(Tf))) >= round(T, floatmax(Tf))
else
@test reinterpret(N(input_typemax)) >= (typemax(T)>>1) # overflow check
@test reinterpret(N(input_typemax)) > (typemax(T)>>1) # overflow check
@test N(input_typemax) >= N(prevfloat(input_typemax))
end

input_upper = Tf(BigFloat(typemax(T)) / r, RoundDown)
Expand Down