Skip to content

Commit dfc3669

Browse files
committed
Modify scope of variables
1 parent 8fbc64e commit dfc3669

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/FixedPointNumbers.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,6 @@ rawtype(::Type{FixedPoint{T,f}}) where {T <: Integer,f} = T
119119
rawtype(::Type{F}) where {F <: FixedPoint} = rawtype(supertype(F))
120120
rawtype(x::FixedPoint) = rawtype(typeof(x))
121121

122-
# This IOBuffer is used during module definition to generate typealias names
123-
_iotypealias = IOBuffer()
124-
125122
# Printing. These are used to generate type-symbols, so we need them
126123
# before we include any files.
127124
function showtype(io::IO, ::Type{X}) where {X <: FixedPoint}
@@ -132,10 +129,10 @@ function showtype(io::IO, ::Type{X}) where {X <: FixedPoint}
132129
io
133130
end
134131
function show(io::IO, x::FixedPoint{T,f}) where {T,f}
135-
show(io, round(convert(Float64,x), digits=ceil(Int,f/_log2_10)))
132+
log10_2 = 0.3010299956639812
133+
show(io, round(convert(Float64,x), digits=ceil(Int, f * log10_2)))
136134
get(io, :compact, false) || showtype(io, typeof(x))
137135
end
138-
const _log2_10 = 3.321928094887362
139136

140137
function Base.showarg(io::IO, a::Array{T}, toplevel) where {T<:FixedPoint}
141138
toplevel || print(io, "::")

src/fixed.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ typechar(::Type{X}) where {X <: Fixed} = 'Q'
3131
signbits(::Type{X}) where {X <: Fixed} = 1
3232

3333
for T in (Int8, Int16, Int32, Int64)
34+
io = IOBuffer()
3435
for f in 0:sizeof(T)*8-1
35-
sym = Symbol(String(take!(showtype(_iotypealias, Fixed{T,f}))))
36+
sym = Symbol(String(take!(showtype(io, Fixed{T,f}))))
3637
@eval begin
3738
const $sym = Fixed{$T,$f}
3839
export $sym

src/normed.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ typechar(::Type{X}) where {X <: Normed} = 'N'
2525
signbits(::Type{X}) where {X <: Normed} = 0
2626

2727
for T in (UInt8, UInt16, UInt32, UInt64)
28+
io = IOBuffer()
2829
for f in 1:sizeof(T)*8
29-
sym = Symbol(String(take!(showtype(_iotypealias, Normed{T,f}))))
30+
sym = Symbol(String(take!(showtype(io, Normed{T,f}))))
3031
@eval begin
3132
const $sym = Normed{$T,$f}
3233
export $sym

0 commit comments

Comments
 (0)