Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,20 @@
import posix, strutils
proc `++`(a, b: float): tuple[lower, upper: float] =
let
a {.volatile.} = a
b {.volatile.} = b
orig = fegetround()
discard fesetround FE_DOWNWARD
result.lower = a + b
discard fesetround FE_UPWARD
result.upper = a + b
discard fesetround orig
proc ff(a: float): string = a.formatFloat(ffDefault, 17)
for x, y in [(1.0, 2.0), (0.1, 0.2), (1e100, 1e-100), (1e308, 1e308)].items:
let (d,u) = x ++ y
echo x.ff, " + ", y.ff, " ="
echo " [", d.ff, ", ", u.ff, "]"
echo " size ", (u - d).ff, "\n"

View file

@ -0,0 +1,53 @@
include builtins\VM\pFPU.e -- :%down53 etc
function safe_add(atom a, atom b)
atom low,high
-- NB: be sure to restore the usual/default rounding!
#ilASM{
[32]
lea esi,[a]
call :%pLoadFlt
lea esi,[b]
call :%pLoadFlt
fld st0
call :%down53
fadd st0,st2
lea edi,[low]
call :%pStoreFlt
call :%up53
faddp
lea edi,[high]
call :%pStoreFlt
call :%near53 -- usual/default
[64]
lea rsi,[a]
call :%pLoadFlt
lea rsi,[b]
call :%pLoadFlt
fld st0
call :%down64
fadd st0,st2
lea rdi,[low]
call :%pStoreFlt
call :%up64
faddp
lea rdi,[high]
call :%pStoreFlt
call :%near64 -- usual/default
[]
}
return {low,high}
end function
constant nums = {{1, 2},
{0.1, 0.2},
{1e100, 1e-100},
{1e308, 1e308}}
for i=1 to length(nums) do
atom {a,b} = nums[i]
atom {low,high} = safe_add(a,b)
printf(1,"%.16g + %.16g =\n", {a, b});
printf(1," [%.16g, %.16g]\n", {low, high});
printf(1," size %.16g\n\n", high - low);
end for