old:programmieren:forth:gforth
Fraction (Nachkommastellen)
: frac ( m.f - f) fdup floor f- ;
Verschiedene Programme
\ Dec to Hex convert \ -------------------- \ decimal : d2h hex . decimal cr ; \ gforth -e '$ad . cr bye' \ Hex to Dec convert \ -------------------- \ decimal \ Hexzahl mit $zahl angeben und dann . \ z.B. $af . -> 175 oder $FF . -> 255 \ Arbeitszeit ausrechnen (Eingabe: Anfang_Std Anfang_Min Ende_Std Ende_Min) \ --------------------------------------------------------------------------- : zdiff swap 60 * + rot 60 * rot + - 30 - ; : >9h dup 540 > if 15 - then ; : zeit 60 /mod ." " . 8 emit ." :" dup 10 < if 0 . 8 emit then . ; : az zdiff >9h zeit cr ; \ Arbeitsende bei 9 Std. Arbeitszeit (Eingabe: Std Min) \ ------------------------------------------------------- : ae 30 + 60 /mod rot + 8 + ." " . 8 emit ." :" dup 10 < if 0 . 8 emit then . cr ; \ Summe aller Arbeitsstunden + Reststunden in einer Arbeitswoche \ --------------------------------------------------------------- : tsum depth 2 - 0> if rot + depth 2 - 0 do -rot + loop swap 60 /mod rot + swap then ; : >60 dup 0> if 60 - swap 1 + swap endif swap 39 - swap abs ; : wzdiff tsum >60 swap ." " . 8 emit ." :" dup 10 < if 0 . 8 emit then . cr ;
Osterdatum Berechnung
: odat dup dup 19 mod dup rot 100 / dup dup 3 * 3 + 4 / 15 + swap 8 * 13 + 25 / - rot 19 * + 30 mod swap 2 swap 3 * 3 + 4 / - -rot dup rot 11 / + 29 / - 21 + swap rot dup 4 / + + 7 mod 7 swap - swap dup rot - 7 mod 7 swap - + ; : ost odat dup 31 > if 31 - . 8 emit ." . Apr. " cr else . 8 emit ." . Mrz. " cr then ;
Differenz von Datum1 und Datum2
j2 j1 j1 4e0 fmod f- f- 4e0 f/ floor j2 j1 f- 365e0 f* f+ m1 8.5e0 f/ floor m1 f+ 2e0 f/ floor m1 1e0 f- 30e0 f* f+ m1 7.5e0 f+ 10e0 f/ floor 2e0 f* f- t1 f+ f- j1 4e0 f/ frac 0.9e0 f+ 1/f floor 10e0 m1 7.5e0 f+ f/ floor f* f+ m2 8.5e0 f/ floor m2 f+ 2e0 f/ floor m2 1e0 f- 30e0 f* f+ m2 7.5e0 f+ 10e0 f/ floor 2e0 f* f- t2 f+ f+ j2 4e0 f/ frac 0.9e0 f+ 1/f floor 10e0 m2 7.5e0 f+ f/ floor f* f- f.
old/programmieren/forth/gforth.txt · Last modified: 2023/01/11 20:29 by 127.0.0.1