mirror of
https://github.com/irmen/prog8.git
synced 2024-11-29 17:50:35 +00:00
e35cfd4971
Unfortunately a few routines (minf, maxf, clampf) remain unchanged, because removing the 'f' would make them clash with a builtin function. floats.rndf -> floats.rnd floats.parse_f -> floats.parse floats.rndseedf -> floats.rndseed floats.print_f -> floats.print floats.str_f -> floats.tostr
43 lines
827 B
Lua
43 lines
827 B
Lua
%import textio
|
|
%import floats
|
|
|
|
main {
|
|
const ubyte N_ITER = 10
|
|
const ubyte SIZE = 32
|
|
|
|
float[SIZE] array = 0.0
|
|
|
|
sub testpow(float x, uword y) -> float {
|
|
float tmp = x
|
|
if y==0
|
|
return 1
|
|
repeat y-1 {
|
|
tmp *= x
|
|
}
|
|
return tmp
|
|
}
|
|
|
|
sub start() {
|
|
txt.print("calculating (expecting 3.614007e+12)...\n")
|
|
cbm.SETTIM(0,0,0)
|
|
|
|
float res=0.0
|
|
uword i
|
|
ubyte j
|
|
for i in 0 to N_ITER-1 {
|
|
for j in 0 to SIZE-1 {
|
|
array[j] += testpow(2.5/(i+1.0), j)
|
|
}
|
|
}
|
|
for j in 0 to SIZE-1 {
|
|
res += array[j]
|
|
}
|
|
|
|
floats.print(res)
|
|
txt.nl()
|
|
floats.print(cbm.RDTIM16() / 60.0)
|
|
txt.print(" seconds")
|
|
sys.wait(9999)
|
|
}
|
|
}
|