Skip to content

Commit

Permalink
Merge pull request #66 from milankl/mk/show
Browse files Browse the repository at this point in the history
show without Float??sr(...)
  • Loading branch information
milankl committed Jul 10, 2023
2 parents 6d40ba8 + 3e170af commit 6389506
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 42 deletions.
15 changes: 1 addition & 14 deletions src/bfloat16sr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,7 @@ for t in (Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt
@eval Base.promote_rule(::Type{BFloat16sr}, ::Type{$t}) = BFloat16sr
end

# Showing
function Base.show(io::IO, x::BFloat16sr)
if isinf(x)
print(io, x < 0 ? "-InfB16" : "InfB16")
elseif isnan(x)
print(io, "NaNB16")
else
io2 = IOBuffer()
print(io2,Float32(x))
f = String(take!(io2))
print(io,"BFloat16sr("*f*")")
end
end

Base.show(io::IO, x::BFloat16sr) = show(io,BFloat16(x))
Base.bitstring(x::BFloat16sr) = bitstring(reinterpret(UInt16,x))

function Base.bitstring(x::BFloat16sr,mode::Symbol)
Expand Down
14 changes: 1 addition & 13 deletions src/float16sr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,7 @@ for func in (:atan,:hypot)
end
end

function Base.show(io::IO, x::Float16sr)
if isinf(x)
print(io, x < 0 ? "-Inf16" : "Inf16")
elseif isnan(x)
print(io, "NaN16")
else
io2 = IOBuffer()
print(io2,Float32(x))
f = String(take!(io2))
print(io,"Float16sr("*f*")")
end
end

Base.show(io::IO, x::Float16sr) = show(io,Float16(x))
Base.bitstring(x::Float16sr) = bitstring(reinterpret(UInt16,x))

function Base.bitstring(x::Float16sr,mode::Symbol)
Expand Down
16 changes: 1 addition & 15 deletions src/float32sr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,7 @@ for func in (:atan,:hypot)
end
end


# Showing
function Base.show(io::IO, x::Float32sr)
if isinf(x)
print(io, x < 0 ? "-Inf32sr" : "Inf32sr")
elseif isnan(x)
print(io, "NaN32sr")
else
io2 = IOBuffer()
print(io2,Float32(x))
f = String(take!(io2))
print(io,"Float32sr("*f*")")
end
end

Base.show(io::IO, x::Float32sr) = show(io,Float32(x))
Base.bitstring(x::Float32sr) = bitstring(reinterpret(UInt32,x))

function Base.bitstring(x::Float32sr,mode::Symbol)
Expand Down

0 comments on commit 6389506

Please sign in to comment.