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