interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / ng / front / cases / fma_mix.om

35 lines · 1038 bytes Raw Blame History
1note fma_mix: fma rounds once. f64 a = 1 + 2^-30, b = 1 - 2^-30, c = -1 (bit patterns below, from Wolfram;
2note groups4.expect): fma a b c is -2^-60 exactly, while mul then add rounds a*b = 1 - 2^-60 to 1 and gives
3note +0. f32 with 2^-13: -2^-26 against +0. Output: those four bit patterns, 8 bytes each, little-endian.
4global o uchar 32
5fn put8 p ulong v ulong to void
6for j ulong 8
7put o add p j uchar and shr v mul j 8 255
8end
9end
10fn ff a f64 b f64 c f64 to f64
11ret fma a b c
12end
13fn fu a f64 b f64 c f64 to f64
14ret add mul a b c
15end
16fn gf a f32 b f32 c f32 to f32
17ret fma a b c
18end
19fn gu a f32 b f32 c f32 to f32
20ret add mul a b c
21end
22fn main to int
23a = bitcast f64 ulong 4607182418804211712
24b = bitcast f64 ulong 4607182418791628800
25c = bitcast f64 ulong 13830554455654793216
26put8 0 bitcast ulong ff a b c
27put8 8 bitcast ulong fu a b c
28p = bitcast f32 uint 1065354240
29q = bitcast f32 uint 1065351168
30r = bitcast f32 uint 3212836864
31put8 16 ulong bitcast uint gf p q r
32put8 24 ulong bitcast uint gu p q r
33w = write 1 o 0 32
34ret 0
35end