From 37e1ec362a686083c4fe3a7201e5eeb48cd58fcd Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Sat, 10 Oct 2026 11:07:27 +0000 Subject: [PATCH] Step 12: F32, and real constants that take F32 or F64 F32 arithmetic, comparisons and conversions use the single precision SSE instructions; F32 goes to and from C and code procedures in xmm registers. A real literal is an untyped constant, folded in double precision and rounded once to the type it takes. An F32 given to ... is an error. --- diff --git a/CLAUDE.md b/CLAUDE.md index b287937..22582eb 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -38,9 +38,8 @@ ## Where things stand Stages 1 and 2 are done (steps 1-10). Stage 3 (steps 11-14) is under -way: its report changes are written and approved, and step 11 is done. -Next is step 12, `F32`, which also makes an `F32` given to `...` an -error. +way: its report changes are written and approved, and steps 11 and 12 +are done. Next is step 13, threads and a thread-safe heap. `test/libc` runs its programs over `lib/Sys.jed`, the C one, through a link in its `mods`. A test or example without `.expect` is only @@ -78,6 +77,9 @@ name like `Rt.exit`, before any module body runs. - Past an extern's parameters, a string goes as a C string and an integer constant as an `I64`. +- A real constant is held as an F64; one typed `F32` holds a value an + F32 can hold. An `F32` in a register is its low 32 bits; the upper + ones are left as they fall. - Every failed check says "index out of range"; some errors point at the symbol after the offending expression. Error messages are to be improved later, all together. diff --git a/PLAN.md b/PLAN.md index e030e23..5fcb551 100644 --- a/PLAN.md +++ b/PLAN.md @@ -112,7 +112,7 @@ at each newline when standard output is a terminal, when full, by `Out.flush`, and at exit. The report says how to mix `Out` with C's `stdio`: flush one before using the other. -- [ ] 12. `F32`: arithmetic, conversions, calls; real literals become +- [x] 12. `F32`: arithmetic, conversions, calls; real literals become untyped constants that take `F32` or `F64`. - [ ] 13. A thread-safe `lib/Heap.jed`: its bad sizes refused, and a marker in each block's header so that freeing a block twice, or diff --git a/src/gen.pas b/src/gen.pas index 43aa669..1acf0e7 100644 --- a/src/gen.pas +++ b/src/gen.pas @@ -154,12 +154,28 @@ x.val := v; end; +{ A real constant: untyped, unless typed later. Its value is an F64, + which for an F32 is one an F32 can hold. } procedure MakeReal(var x: TItem; r: double); begin - MakeConst(x, tReal, 0); + MakeConst(x, tRConst, 0); Move(r, x.val, 8); end; +function IsF32(t: PType): boolean; +begin + IsF32 := (t^.form = fReal) and (t^.size = 4); +end; + +{ Gives a real constant the real type t, rounded to it. } +procedure RealTo(var x: TItem; t: PType); +var r: double; +begin + r := RealOf(x); + if IsF32(t) then MakeReal(x, single(r)) else MakeReal(x, r); + x.typ := t; +end; + function RealOf(const x: TItem): double; var r: double; begin @@ -233,9 +249,13 @@ { A constant into r: an error constant is the address of its chunk. } procedure ConstTo(r: longint; const x: TItem); +var f: single; begin if (x.typ^.form = fError) and (x.val > 0) then Lea(r, MemRip(x.val - 1, 0)) - else MovRI(r, x.val); + else if IsF32(x.typ) then begin + f := RealOf(x); + MovRI(r, PLongword(@f)^); + end else MovRI(r, x.val); end; function MemOf(var x: TItem; r: longint): TMem; @@ -259,7 +279,7 @@ function ScalarSize(t: PType): longint; begin - if t^.form in [fInt, fBool, fEnum, fSet] then ScalarSize := t^.size + if t^.form in [fInt, fBool, fEnum, fSet, fReal] then ScalarSize := t^.size else ScalarSize := 8; end; @@ -427,7 +447,8 @@ end; if x.mode in [mType, mBuiltin, mNone, mCase] then Mark('not a value'); if Same(s, t) then exit; - if (s^.form = fConst) and (t^.form = fInt) then begin + if (s = tRConst) and (t^.form = fReal) then RealTo(x, t) + else if (s^.form = fConst) and (t^.form = fInt) then begin if (x.mode = mConst) and not Fits(x.val, t) then Mark('constant doesn''t fit ' + TypeName(t)); x.typ := t; end else if (s^.form = fNil) and (t^.form in [fPtr, fProc, fError]) then @@ -605,7 +626,7 @@ begin if x.typ^.form = fReal then begin if x.mode = mConst then x.val := x.val xor low(int64) - else begin Value(x); Btc(RAX, 63) end; + else begin Value(x); if IsF32(x.typ) then Btc(RAX, 31) else Btc(RAX, 63) end; end else if IsInt(x.typ) then begin if x.mode = mConst then x.val := Cut(-x.val, x.typ) else begin Value(x); Unary(3, RAX); Norm(x.typ) end; @@ -706,7 +727,9 @@ end; end; -function FoldReal(op: TSym; const x, y: TItem; var r: TItem): boolean; +{ Folds x op y, of the real type t: an F32 rounded at each step, as + the machine would. } +function FoldReal(op: TSym; const x, y: TItem; t: PType; var r: TItem): boolean; var a, b: double; begin a := RealOf(x); b := RealOf(y); @@ -724,6 +747,7 @@ sGeq: MakeConst(r, tBool, ord(a >= b)); else FoldReal := false; end; + if r.typ^.form = fReal then RealTo(r, t); end; procedure Op2(op: TSym; var x, y: TItem; L: longint); @@ -732,7 +756,7 @@ CcSigned: array[sEql..sGeq] of longint = (ccE, ccNE, ccL, ccLE, ccG, ccGE); CcUnsigned: array[sEql..sGeq] of longint = (ccE, ccNE, ccB, ccBE, ccA, ccAE); var - xt, yt, t: PType; r: TItem; scale, sh: longint; isPtr, unsign: boolean; a, b: int64; + xt, yt, t: PType; r: TItem; scale, sh: longint; isPtr, unsign, f: boolean; a, b: int64; begin xt := x.typ; yt := y.typ; if y.mode in [mType, mBuiltin, mNone, mCase] then Mark('not a value'); @@ -768,7 +792,7 @@ { the type of the result, and the checks } t := nil; scale := 1; isPtr := false; if IsInt(xt) and IsInt(yt) then begin - if op = sSlash then Mark('/ is for F64; integers use div'); + if op = sSlash then Mark('/ is for reals; integers use div'); if op in [sShl, sShr] then begin if xt^.form = fConst then t := tConst else t := xt end else if (xt^.form = fConst) and (yt^.form = fConst) then t := tConst @@ -781,8 +805,12 @@ end else if Same(xt, yt) then t := xt else Mark('different types: ' + TypeName(xt) + ' and ' + TypeName(yt)); end else if (xt^.form = fReal) and (yt^.form = fReal) then begin - if not (op in Rel + [sPlus, sMinus, sTimes, sSlash]) then Mark('not an F64 operator'); - t := tReal; + if not (op in Rel + [sPlus, sMinus, sTimes, sSlash]) then Mark('not a real operator'); + if xt = tRConst then t := yt + else if (yt = tRConst) or Same(xt, yt) then t := xt + else Mark('different types: ' + TypeName(xt) + ' and ' + TypeName(yt)); + if (x.mode = mConst) and (x.typ <> t) then RealTo(x, t); + if (y.mode = mConst) and (y.typ <> t) then RealTo(y, t); end else if (xt^.form = fBool) and (yt^.form = fBool) then begin if not (op in [sXor, sEql, sNeq]) then Mark('not a BOOL operator'); t := tBool; @@ -815,7 +843,7 @@ { constants } if (x.mode = mConst) and (y.mode = mConst) and not isPtr then begin if t^.form = fReal then begin - if not FoldReal(op, x, y, r) then Mark('not an F64 operator'); + if not FoldReal(op, x, y, t, r) then Mark('not a real operator'); x := r; end else if t^.form = fSet then begin a := x.val; b := y.val; @@ -848,17 +876,18 @@ if t^.form = fReal then begin MovqXR(0, RAX); MovqXR(1, RCX); + f := IsF32(t); case op of - sPlus: Sse($58, 0, 1); - sMinus: Sse($5C, 0, 1); - sTimes: Sse($59, 0, 1); - sSlash: Sse($5E, 0, 1); - sEql: begin Ucomisd(0, 1); SetCC(ccE, RAX); SetCC(ccNP, RCX); Alu(aluAnd, RAX, RCX) end; - sNeq: begin Ucomisd(0, 1); SetCC(ccNE, RAX); SetCC(ccP, RCX); Alu(aluOr, RAX, RCX) end; - sLss: begin Ucomisd(1, 0); SetCC(ccA, RAX) end; - sLeq: begin Ucomisd(1, 0); SetCC(ccAE, RAX) end; - sGtr: begin Ucomisd(0, 1); SetCC(ccA, RAX) end; - sGeq: begin Ucomisd(0, 1); SetCC(ccAE, RAX) end; + sPlus: Sse($58, 0, 1, f); + sMinus: Sse($5C, 0, 1, f); + sTimes: Sse($59, 0, 1, f); + sSlash: Sse($5E, 0, 1, f); + sEql: begin Ucomis(0, 1, f); SetCC(ccE, RAX); SetCC(ccNP, RCX); Alu(aluAnd, RAX, RCX) end; + sNeq: begin Ucomis(0, 1, f); SetCC(ccNE, RAX); SetCC(ccP, RCX); Alu(aluOr, RAX, RCX) end; + sLss: begin Ucomis(1, 0, f); SetCC(ccA, RAX) end; + sLeq: begin Ucomis(1, 0, f); SetCC(ccAE, RAX) end; + sGtr: begin Ucomis(0, 1, f); SetCC(ccA, RAX) end; + sGeq: begin Ucomis(0, 1, f); SetCC(ccAE, RAX) end; end; if not (op in Rel) then MovqRX(RAX, 0); end else if t^.form = fSet then begin @@ -915,7 +944,7 @@ end; procedure Convert(var x: TItem; t: PType); -var s: PType; r: double; L1, L2: longint; +var s: PType; r: double; L1, L2: longint; f: boolean; begin s := x.typ; if x.mode in [mType, mBuiltin, mNone, mCase, mStr] then Mark('can''t convert this'); @@ -935,9 +964,11 @@ if t^.len < 64 then begin MovRI(RCX, (int64(1) shl t^.len) - 1); Alu(aluAnd, RAX, RCX) end; end; end else if IsInt(s) and (t^.form = fReal) then begin + f := IsF32(t); if x.mode = mConst then begin if (s^.form = fInt) and not s^.signed then r := qword(x.val) else r := x.val; MakeReal(x, r); + RealTo(x, t); end else begin Value(x); if (s^.form = fInt) and not s^.signed and (s^.size = 8) then begin @@ -945,19 +976,25 @@ L1 := NoLabel; L2 := NoLabel; TestRR(RAX, RAX); Jcc(ccS, L1); - Cvtsi2sd(0, RAX); + Cvtsi2s(0, RAX, f); Jmp(L2); FixLink(L1); MovRR(RCX, RAX); ShiftI(shShr, RCX, 1); AluI(aluAnd, RAX, 1); Alu(aluOr, RCX, RAX); - Cvtsi2sd(0, RCX); - Sse($58, 0, 0); + Cvtsi2s(0, RCX, f); + Sse($58, 0, 0, f); FixLink(L2); - end else Cvtsi2sd(0, RAX); + end else Cvtsi2s(0, RAX, f); MovqRX(RAX, 0); end; + end else if (s^.form = fReal) and (t^.form = fReal) then begin + { F32 to F64, F64 to F32, or a real constant to either } + if x.mode = mConst then RealTo(x, t) + else begin + Value(x); MovqXR(0, RAX); Sse($5A, 0, 0, IsF32(s)); MovqRX(RAX, 0) + end; end else if (s^.form = fReal) and (t^.form = fInt) then begin if x.mode = mConst then begin r := RealOf(x); @@ -965,7 +1002,7 @@ x.val := Cut(low(int64), t) else x.val := Cut(trunc(r), t); end else begin - Value(x); MovqXR(0, RAX); Cvttsd2si(RAX, 0); Norm(t) + Value(x); MovqXR(0, RAX); Cvtts2si(RAX, 0, IsF32(s)); Norm(t) end; end else if (IsInt(s) or (s^.form in [fPtr, fProc, fNil])) and (t^.form in [fPtr, fProc]) then begin if x.mode <> mConst then Value(x); @@ -1000,10 +1037,13 @@ if c.n > High(c.slots) then Mark('too many arguments'); if p = nil then begin { past the parameters of a C procedure that ends in ...: a string - goes as a C string, an integer constant as an I64 } + goes as a C string, an integer constant as an I64, a real + constant as an F64; C takes no F32 there } if not c.sig^.variadic then Mark('too many arguments'); if a.mode = mStr then Coerce(a, tPtrU8) else if a.typ^.form = fConst then Coerce(a, tI64) + else if a.typ = tRConst then Coerce(a, tReal) + else if IsF32(a.typ) then Mark('an F32 goes to ... as F64(x)') else if not IsScalar(a.typ) then Mark('only a single value goes to ...'); c.isF[c.n] := a.typ^.form = fReal; c.slots[c.n] := ToSlot(a); diff --git a/src/parse.pas b/src/parse.pas index a2b4fb1..5238608 100644 --- a/src/parse.pas +++ b/src/parse.pas @@ -1283,7 +1283,7 @@ q := sig^.fields; while q <> nil do begin if not q^.isVar and not IsScalar(q^.typ) then - Mark('a code procedure takes integers, BOOL, F64, pointers and procedures'); + Mark('a code procedure takes integers, BOOL, reals, pointers and procedures'); if (q^.typ^.form = fReal) and not q^.isVar then inc(nf) else inc(ni); q := q^.next; end; @@ -1362,7 +1362,7 @@ q := t^.fields; while q <> nil do begin if q^.isVar or not IsScalar(q^.typ) then - Mark('C takes integers, BOOL, F64, pointers and procedures'); + Mark('C takes integers, BOOL, reals, pointers and procedures'); q := q^.next; end; if (t^.base <> nil) and not IsScalar(t^.base) then Mark('C returns a single value'); diff --git a/src/sym.pas b/src/sym.pas index 7a7bf9c..21636cc 100644 --- a/src/sym.pas +++ b/src/sym.pas @@ -23,7 +23,8 @@ TForm = (fNone, fBool, fInt, fReal, fConst, fNil, fStr, fPtr, fArray, fSlice, fRecord, fVariant, fProc, fEnum, fSet, fError); { fConst is the type of an untyped integer constant; fStr of a string - literal, whose length the literal carries } + literal, whose length the literal carries. F32 and F64 are fReal, + told apart by size, and so is tRConst, an untyped real constant. } TClass = (oConst, oType, oVar, oProc, oModule, oField, oCase, oBuiltin); @@ -120,7 +121,7 @@ var tI8, tI16, tI32, tI64, tU8, tU16, tU32, tU64: PType; - tBool, tReal, tError, tConst, tNil, tStr, tNone, tPtrU8, tBytes: PType; + tBool, tF32, tReal, tRConst, tError, tConst, tNil, tStr, tNone, tPtrU8, tBytes: PType; curModule: PModule; function NewType(form: TForm; size, align: int64): PType; @@ -372,6 +373,7 @@ end; case t^.form of fConst: TypeName := 'an integer constant'; + fReal: TypeName := 'a real constant'; fNil: TypeName := 'nil'; fStr: TypeName := 'a string'; fPtr: if t^.vol then TypeName := '^VOLATILE ' + TypeName(t^.base) @@ -473,7 +475,9 @@ tU32 := Basic('U32', fInt, 4, false); tU64 := Basic('U64', fInt, 8, false); tBool := Basic('BOOL', fBool, 1, false); + tF32 := Basic('F32', fReal, 4, false); tReal := Basic('F64', fReal, 8, false); + tRConst := NewType(fReal, 8, 8); tError := Basic('ERROR', fError, 8, false); tConst := NewType(fConst, 8, 8); tConst^.signed := true; diff --git a/src/x64.pas b/src/x64.pas index 58d008a..8f06ee8 100644 --- a/src/x64.pas +++ b/src/x64.pas @@ -135,10 +135,11 @@ procedure MovqRX(r, x: longint); procedure MovsdXM(x: longint; const m: TMem); procedure MovsdMX(const m: TMem; x: longint); -procedure Sse(op, x, y: longint); { F2 0F op: 58 add, 59 mul, 5C sub, 5E div } -procedure Ucomisd(x, y: longint); -procedure Cvtsi2sd(x, r: longint); -procedure Cvttsd2si(r, x: longint); +{ The real instructions take single: F32 (ss) rather than F64 (sd) } +procedure Sse(op, x, y: longint; single: boolean); { 58 add, 59 mul, 5C sub, 5E div, 5A convert } +procedure Ucomis(x, y: longint; single: boolean); +procedure Cvtsi2s(x, r: longint; single: boolean); +procedure Cvtts2si(r, x: longint; single: boolean); procedure Btc(r, bit: longint); procedure Jmp(var L: longint); @@ -554,24 +555,27 @@ OpM($F2, false, $110F, x, m); end; -procedure Sse(op, x, y: longint); +const + RealPfx: array[boolean] of longint = ($F2, $F3); + +procedure Sse(op, x, y: longint; single: boolean); begin - OpR($F2, false, $0F or op shl 8, x, y); + OpR(RealPfx[single], false, $0F or op shl 8, x, y); end; -procedure Ucomisd(x, y: longint); +procedure Ucomis(x, y: longint; single: boolean); begin - OpR($66, false, $2E0F, x, y); + if single then OpR(0, false, $2E0F, x, y) else OpR($66, false, $2E0F, x, y); end; -procedure Cvtsi2sd(x, r: longint); +procedure Cvtsi2s(x, r: longint; single: boolean); begin - OpR($F2, true, $2A0F, x, r); + OpR(RealPfx[single], true, $2A0F, x, r); end; -procedure Cvttsd2si(r, x: longint); +procedure Cvtts2si(r, x: longint; single: boolean); begin - OpR($F2, true, $2C0F, r, x); + OpR(RealPfx[single], true, $2C0F, r, x); end; procedure Btc(r, bit: longint); diff --git a/test/enctest.pas b/test/enctest.pas index 1945c43..07668c1 100644 --- a/test/enctest.pas +++ b/test/enctest.pas @@ -24,7 +24,9 @@ Push(RAX); Push(12); Pop(RCX); Pop(R11); CallR(R11); CallM(Mem(RCX, 8)); Ret; Leave; Syscall; Mfence; Ud2; RepMovsb; RepStosb; LockCmpxchg(Mem(RCX, 0), RDX); Xchg(Mem(RCX, 0), RAX); LockXadd(Mem(RCX, 0), RAX); MovqXR(0, RAX); MovqXR(1, RCX); MovqRX(RAX, 0); MovsdXM(2, Mem(RBP, -8)); MovsdMX(Mem(RBP, -8), 7); - Sse($58, 0, 1); Sse($5E, 0, 1); Ucomisd(0, 1); Cvtsi2sd(0, RAX); Cvttsd2si(RAX, 0); Btc(RAX, 63); + Sse($58, 0, 1, false); Sse($5E, 0, 1, true); Sse($5A, 0, 0, false); Sse($5A, 0, 0, true); + Ucomis(0, 1, false); Ucomis(0, 1, true); Cvtsi2s(0, RAX, false); Cvtsi2s(0, RAX, true); + Cvtts2si(RAX, 0, false); Cvtts2si(RAX, 0, true); Btc(RAX, 63); L := NoLabel; Jcc(ccE, L); Jmp(L); FixLink(L); JmpBack(chunks^[e].start); JccBack(ccNE, chunks^[e].start); EndChunk(e); WriteElf(ParamStr(1), e); diff --git a/test/err/ExternRec.err b/test/err/ExternRec.err index 817cd5b..9fe8e4e 100644 --- a/test/err/ExternRec.err +++ b/test/err/ExternRec.err @@ -1 +1 @@ -C takes integers, BOOL, F64, pointers and procedures +C takes integers, BOOL, reals, pointers and procedures diff --git a/test/err/F32Dots.err b/test/err/F32Dots.err new file mode 100644 index 0000000..c1fd5a4 --- /dev/null +++ b/test/err/F32Dots.err @@ -0,0 +1 @@ +an F32 goes to ... as F64(x) diff --git a/test/err/F32Dots.jed b/test/err/F32Dots.jed new file mode 100644 index 0000000..445d23d --- /dev/null +++ b/test/err/F32Dots.jed @@ -0,0 +1,11 @@ +module F32Dots; +import C; + +proc main*; +var x: F32; +begin + x := 1.5; + C.printf("%f\n", x); +end; + +end F32Dots. diff --git a/test/err/Mixed.err b/test/err/Mixed.err new file mode 100644 index 0000000..bae9e76 --- /dev/null +++ b/test/err/Mixed.err @@ -0,0 +1 @@ +different types: F32 and F64 diff --git a/test/err/Mixed.jed b/test/err/Mixed.jed new file mode 100644 index 0000000..693f8e4 --- /dev/null +++ b/test/err/Mixed.jed @@ -0,0 +1,9 @@ +module Mixed; + +proc main*; +var x: F32; y: F64; +begin + y := x + y; +end; + +end Mixed. diff --git a/test/run/Single.expect b/test/run/Single.expect new file mode 100644 index 0000000..5268733 --- /dev/null +++ b/test/run/Single.expect @@ -0,0 +1,22 @@ +4 12 +a+b 0.300000012 +d+0.2 0.3 +third 0.333333343 +1/3 0.333333343 +ten tenths 1.00000012 +not one +near one +negated -1 +I64(-2.75) -2 +10000000000 +U64 max 1.84467441e+19 +I32 big 16777216 +F32(1E40) inf +F32(1/3) 0.333333343 +dot 7 +sqrtf 1.41421354 +fabsf 1.5 +twice 2.5 +mix 3.875 +arr 1.5 +0.500000 0.500000 diff --git a/test/run/Single.jed b/test/run/Single.jed new file mode 100644 index 0000000..32ce2ab --- /dev/null +++ b/test/run/Single.jed @@ -0,0 +1,81 @@ +(* F32: arithmetic rounded at each step, conversions, real constants + that take either type, calls to C and to code. *) +module Single; +import Out, C; +link "libm.so.6"; + +const + third = 1.0 / 3.0; (* in double precision, then rounded once *) + tenth = 0.1; + +type + Vec = record x, y, z: F32; end; + +extern proc sqrtf(x: F32): F32; +extern proc fabsf(x: F32): F32; +extern proc sqrt(x: F64): F64; + +(* addss xmm0, xmm0; ret *) +proc twice(x: F32): F32; +code 0F3H, 0FH, 58H, 0C0H, 0C3H; + +proc dot(a, b: Vec): F32; +begin + return a.x * b.x + a.y * b.y + a.z * b.z; +end; + +proc mix(a: F32; n: I64; b: F64; c: F32): F64; +begin + return F64(a) + F64(n) + b + F64(c); +end; + +proc show(name: ^U8; x: F64); +begin + Out.flush; + C.printf("%s %.9g\n", name, x); + C.fflush(C.stdout); +end; + +proc main*; +var + a, b, s: F32; d: F64; v, w: Vec; i: I64; big: U64; arr: [4]F32; +begin + Out.int(SIZE(F32)); Out.char(' '); Out.int(SIZE(Vec)); Out.ln; + a := tenth; + b := 0.2; + show("a+b", F64(a + b)); + d := tenth; + show("d+0.2", d + 0.2); + a := third; + show("third", F64(a)); + a := 1.0; + b := 3.0; + show("1/3", F64(a / b)); + s := 0.0; + for i := 1 to 10 do s := s + tenth; end; + show("ten tenths", F64(s)); + if s # 1.0 then Out.str("not one\n"); end; + if (s > 0.9) and (s <= 1.1) and not (s < 0.0) then Out.str("near one\n"); end; + a := -a; + show("negated", F64(a)); + show("I64(-2.75)", F64(I64(F32(-2.75)))); + Out.int(I64(F32(1.0E10))); Out.ln; + big := 0FFFFFFFFFFFFFFFFH; + show("U64 max", F64(F32(big))); + show("I32 big", F64(F32(I32(16777217)))); + show("F32(1E40)", F64(F32(d * 1.0E41))); + show("F32(1/3)", F64(F32(1.0 / 3.0))); + v := {x: 1.0, y: 2.0, z: 3.0}; + w := {x: 0.5, y: 0.25, z: 2.0}; + show("dot", F64(dot(v, w))); + show("sqrtf", F64(sqrtf(2.0))); + show("fabsf", F64(fabsf(-1.5))); + show("twice", F64(twice(1.25))); + show("mix", mix(1.5, 2, 0.25, 0.125)); + for i := 0 to 3 do arr[i] := F32(i) * 0.5; end; + show("arr", F64(arr[3])); + C.printf("%f %f\n", F64(arr[1]), 0.5); + C.fflush(C.stdout); +end; + +end Single.