tricu

A lazy functional language based on Tree Calculus
Log | Files | Refs | README | LICENSE

54d9283cce0827f850ffcf1b1c0c137a1cc689aa4188e0e183a3e49add7e7b69.tri (524B)


      1 -- Input: pair of IEEE binary64 words. Output: Result (word, flags).
      2 -- Compute x*y + x, rounding separately after multiplication and addition.
      3 !import base as B
      4 !import binary64 as F
      5 !export main
      6 main input = B.bindResult
      7   (B.checkContract (B.pairOf F.fromBitsC F.fromBitsC) input)
      8   (values _ : let x = B.fst values in let y = B.snd values in
      9     let product = F.multiply x y in
     10     let sum = F.add (F.value product) x in
     11     B.ok (B.pair (F.toBits (F.value sum))
     12       (F.mergeFlags (F.flags product) (F.flags sum))) t)