Skip to content

Commit d078879

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 d1be6d4 commit d078879

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

@@ -23,13 +23,13 @@ Base.@propagate_inbounds function mand8(cr, ci)
2323

2424
for _=1:10
2525
for _=1:5
26-
Zi = 2f0 .* Zr .* Zi .+ ci
26+
Zi = 2.0 .* Zr .* Zi .+ ci
2727
Zr = Tr .- Ti .+ cr
2828
Tr = Zr .* Zr
2929
Ti = Zi .* Zi
3030
end
3131
t = Tr .+ Ti
32-
all(x-> x > 4f0, t) && (return 0x00)
32+
all(x-> x > 4.0, t) && (return 0x00)
3333
end
3434

3535
byte = 0xff
@@ -48,8 +48,8 @@ end
4848

4949
function mandelbrot(io, n = 200)
5050
inv_ = 2.0 / n
51-
xvals = Vector{Float32}(undef, n)
52-
yvals = Vector{Float32}(undef, n)
51+
xvals = Vector{Float64}(undef, n)
52+
yvals = Vector{Float64}(undef, n)
5353
@inbounds for i in 0:(n-1)
5454
xvals[i + 1] = i * inv_ - 1.5
5555
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

@@ -23,13 +23,13 @@ Base.@propagate_inbounds function mand8(cr, ci)
2323

2424
for _=1:10
2525
for _=1:5
26-
Zi = 2f0 .* Zr .* Zi .+ ci
26+
Zi = 2.0 .* Zr .* Zi .+ ci
2727
Zr = Tr .- Ti .+ cr
2828
Tr = Zr .* Zr
2929
Ti = Zi .* Zi
3030
end
3131
t = Tr .+ Ti
32-
all(x-> x > 4f0, t) && (return 0x00)
32+
all(x-> x > 4.0, t) && (return 0x00)
3333
end
3434

3535
byte = 0xff
@@ -48,8 +48,8 @@ end
4848

4949
function mandelbrot(io, n = 200)
5050
inv_ = 2.0 / n
51-
xvals = Vector{Float32}(undef, n)
52-
yvals = Vector{Float32}(undef, n)
51+
xvals = Vector{Float64}(undef, n)
52+
yvals = Vector{Float64}(undef, n)
5353
@inbounds for i in 0:(n-1)
5454
xvals[i + 1] = i * inv_ - 1.5
5555
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

@@ -25,13 +25,13 @@ Base.@propagate_inbounds function mand8(cr, ci)
2525

2626
for _=1:10
2727
for _=1:5
28-
Zi = 2f0 .* Zr .* Zi .+ ci
28+
Zi = 2.0 .* Zr .* Zi .+ ci
2929
Zr = Tr .- Ti .+ cr
3030
Tr = Zr .* Zr
3131
Ti = Zi .* Zi
3232
end
3333
t = Tr .+ Ti
34-
all(x-> x > 4f0, t) && (return 0x00)
34+
all(x-> x > 4.0, t) && (return 0x00)
3535
end
3636

3737
byte = 0xff
@@ -50,8 +50,8 @@ end
5050

5151
function mandelbrot(io, n = 200)
5252
inv_ = 2.0 / n
53-
xvals = Vector{Float32}(undef, n)
54-
yvals = Vector{Float32}(undef, n)
53+
xvals = Vector{Float64}(undef, n)
54+
yvals = Vector{Float64}(undef, n)
5555
@inbounds for i in 0:(n-1)
5656
xvals[i + 1] = i * inv_ - 1.5
5757
yvals[i + 1] = i * inv_ - 1.0

0 commit comments

Comments
 (0)