nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
matrix: use a custom low-level C structure to avoid boxing of param types
[nit.git]
/
tests
/
shootout_mandelbrot.nit
diff --git
a/tests/shootout_mandelbrot.nit
b/tests/shootout_mandelbrot.nit
index
fb6b5dd
..
7970971
100644
(file)
--- a/
tests/shootout_mandelbrot.nit
+++ b/
tests/shootout_mandelbrot.nit
@@
-25,17
+25,17
@@
var iter = 20
var limit = 2.0
if args.length != 1 then
var limit = 2.0
if args.length != 1 then
- printn("Usage: shootout_mandelbrot <size>\n")
+ print("Usage: shootout_mandelbrot <size>")
return
end
var w = args.first.to_i
var h = w
return
end
var w = args.first.to_i
var h = w
-var byte_acc = 0
+var byte_acc = 0u8
var bit_num = 0
var bit_num = 0
-printn("P4\n{w} {h}\n")
+print("P4\n{w} {h}")
for y in [0..h[ do
for x in [0..w[ do
for y in [0..h[ do
for x in [0..w[ do
@@
-54,22
+54,23
@@
for y in [0..h[ do
end
if zr*zr+zi*zi > limit*limit then
end
if zr*zr+zi*zi > limit*limit then
- byte_acc = (byte_acc.lshift(1))
+ byte_acc = byte_acc << 1
else
else
- byte_acc = (byte_acc.lshift(1)) + 1
+ byte_acc = (byte_acc << 1) + 1u8
end
bit_num = bit_num + 1
if bit_num == 8 then
end
bit_num = bit_num + 1
if bit_num == 8 then
- printn(byte_acc.ascii)
- byte_acc = 0
+ stdout.write_byte(byte_acc)
+ byte_acc = 0u8
bit_num = 0
else if x == w - 1 then
bit_num = 0
else if x == w - 1 then
- byte_acc = byte_acc.lshift(8-w%8)
- printn(byte_acc.ascii)
- byte_acc = 0
+ byte_acc = byte_acc << (8-w%8)
+ stdout.write_byte(byte_acc)
+ byte_acc = 0u8
bit_num = 0
end
end
end
bit_num = 0
end
end
end
+print ""