Skip to content

Commit

Permalink
probably fix #3737
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jul 18, 2013
1 parent c84fa90 commit df96f44
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions base/float.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
#bitstype 16 Float16 <: FloatingPoint
## conversions to floating-point ##

convert(::Type{Float32}, x::Int128) = float32(uint128(abs(x)))*(1-2(x<0))
convert(::Type{Float32}, x::Uint128) = float32(uint64(x)) + ldexp(float32(uint64(x>>>64)),64)
promote_rule(::Type{Float32}, ::Type{Int128} ) = Float32
promote_rule(::Type{Float32}, ::Type{Uint128}) = Float32

convert(::Type{Float64}, x::Int128) = float64(uint128(abs(x)))*(1-2(x<0))
convert(::Type{Float64}, x::Uint128) = float64(uint64(x)) + ldexp(float64(uint64(x>>>64)),64)
promote_rule(::Type{Float64}, ::Type{Int128} ) = Float64
promote_rule(::Type{Float64}, ::Type{Uint128}) = Float64

for t1 in (Float32,Float64) #,Float16)
for st in (Int8,Int16,Int32,Int64,Int128)
for st in (Int8,Int16,Int32,Int64)
@eval begin
convert(::Type{$t1},x::($st)) = box($t1,sitofp($t1,unbox($st,x)))
promote_rule(::Type{$t1}, ::Type{$st} ) = $t1
end
end
for ut in (Bool,Char,Uint8,Uint16,Uint32,Uint64,Uint128)
for ut in (Bool,Char,Uint8,Uint16,Uint32,Uint64)
@eval begin
convert(::Type{$t1},x::($ut)) = box($t1,uitofp($t1,unbox($ut,x)))
promote_rule(::Type{$t1}, ::Type{$ut} ) = $t1
Expand Down

1 comment on commit df96f44

@JeffBezanson
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong issue number in commit message. Probably fixes #3741

Please sign in to comment.