Skip to content

Commit 204f6e3

Browse files
committed
Convert to using Float64 instead of Float32
Different results obtained for higher n with Float32 than other implementations, so it's not allowed.
1 parent 0fa8313 commit 204f6e3

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

mandelbrot/mandelbrot-fast.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The Computer Language Benchmarks Game
88
modified for Julia 1.0 by Simon Danisch.
99
tweaked for performance by https://github.com/maltezfaria and Adam Beckmeyer.
1010
=#
11-
const zerov8 = ntuple(x-> 0f0, 8)
11+
const zerov8 = ntuple(x-> 0.0, 8)
1212
const masks = (0b01111111, 0b10111111, 0b11011111, 0b11101111, 0b11110111,
1313
0b11111011, 0b11111101, 0b11111110)
1414

@@ -19,13 +19,13 @@ Base.@propagate_inbounds function mand8(cr, ci)
1919

2020
for _=1:10
2121
for _=1:5
22-
Zi = 2f0 .* Zr .* Zi .+ ci
22+
Zi = 2.0 .* Zr .* Zi .+ ci
2323
Zr = Tr .- Ti .+ cr
2424
Tr = Zr .* Zr
2525
Ti = Zi .* Zi
2626
end
2727
t = Tr .+ Ti
28-
all(x-> x > 4f0, t) && (return 0x00)
28+
all(x-> x > 4.0, t) && (return 0x00)
2929
end
3030

3131
byte = 0xff
@@ -44,8 +44,8 @@ end
4444

4545
function mandelbrot(io, n = 200)
4646
inv_ = 2.0 / n
47-
xvals = Vector{Float32}(undef, n)
48-
yvals = Vector{Float32}(undef, n)
47+
xvals = Vector{Float64}(undef, n)
48+
yvals = Vector{Float64}(undef, n)
4949
@inbounds for i in 0:(n-1)
5050
xvals[i + 1] = i * inv_ - 1.5
5151
yvals[i + 1] = i * inv_ - 1.0

mandelbrot/mandelbrot-fast.v2.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The Computer Language Benchmarks Game
88
modified for Julia 1.0 by Simon Danisch.
99
tweaked for performance by https://github.com/maltezfaria and Adam Beckmeyer.
1010
=#
11-
const zerov8 = ntuple(x-> 0f0, 8)
11+
const zerov8 = ntuple(x-> 0.0, 8)
1212
const masks = (0b01111111, 0b10111111, 0b11011111, 0b11101111, 0b11110111,
1313
0b11111011, 0b11111101, 0b11111110)
1414

@@ -19,13 +19,13 @@ Base.@propagate_inbounds function mand8(cr, ci)
1919

2020
for _=1:10
2121
for _=1:5
22-
Zi = 2f0 .* Zr .* Zi .+ ci
22+
Zi = 2.0 .* Zr .* Zi .+ ci
2323
Zr = Tr .- Ti .+ cr
2424
Tr = Zr .* Zr
2525
Ti = Zi .* Zi
2626
end
2727
t = Tr .+ Ti
28-
all(x-> x > 4f0, t) && (return 0x00)
28+
all(x-> x > 4.0, t) && (return 0x00)
2929
end
3030

3131
byte = 0xff
@@ -44,8 +44,8 @@ end
4444

4545
function mandelbrot(io, n = 200)
4646
inv_ = 2.0 / n
47-
xvals = Vector{Float32}(undef, n)
48-
yvals = Vector{Float32}(undef, n)
47+
xvals = Vector{Float64}(undef, n)
48+
yvals = Vector{Float64}(undef, n)
4949
@inbounds for i in 0:(n-1)
5050
xvals[i + 1] = i * inv_ - 1.5
5151
yvals[i + 1] = i * inv_ - 1.0

mandelbrot/mandelbrot-fast.v3.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The Computer Language Benchmarks Game
1010
=#
1111
using KissThreading
1212

13-
const zerov8 = ntuple(x-> 0f0, 8)
13+
const zerov8 = ntuple(x-> 0.0, 8)
1414
const masks = (0b01111111, 0b10111111, 0b11011111, 0b11101111, 0b11110111,
1515
0b11111011, 0b11111101, 0b11111110)
1616

@@ -21,13 +21,13 @@ Base.@propagate_inbounds function mand8(cr, ci)
2121

2222
for _=1:10
2323
for _=1:5
24-
Zi = 2f0 .* Zr .* Zi .+ ci
24+
Zi = 2.0 .* Zr .* Zi .+ ci
2525
Zr = Tr .- Ti .+ cr
2626
Tr = Zr .* Zr
2727
Ti = Zi .* Zi
2828
end
2929
t = Tr .+ Ti
30-
all(x-> x > 4f0, t) && (return 0x00)
30+
all(x-> x > 4.0, t) && (return 0x00)
3131
end
3232

3333
byte = 0xff
@@ -46,8 +46,8 @@ end
4646

4747
function mandelbrot(io, n = 200)
4848
inv_ = 2.0 / n
49-
xvals = Vector{Float32}(undef, n)
50-
yvals = Vector{Float32}(undef, n)
49+
xvals = Vector{Float64}(undef, n)
50+
yvals = Vector{Float64}(undef, n)
5151
@inbounds for i in 0:(n-1)
5252
xvals[i + 1] = i * inv_ - 1.5
5353
yvals[i + 1] = i * inv_ - 1.0

0 commit comments

Comments
 (0)