gr_cmp.miaou
← Le code · src/outil/miaou/gr_cmp.miaou · 23 lignes
(node gr_cmp
(params (a Grand) (b Grand))
(returns Ent)
(intent "la comparaison des grands entiers normalisés a et b, signes compris : -1, 0 ou 1")
(origin "phase 8f6 : les valeurs en miaou, d'après g_cmp de l'outil inter")
(effects)
(uses gr_cmp_abs)
(requires
true)
(ensures
(and (ge r -1) (le r 1)))
(examples
(ex ((record Grand (neg false) (mots (list 5))) (record Grand (neg false) (mots (list 7)))) -1)
(ex ((record Grand (neg true) (mots (list 5))) (record Grand (neg true) (mots (list 7)))) 1)
(ex ((record Grand (neg true) (mots (list 1))) (record Grand (neg false) (mots (list)))) -1)
(ex ((record Grand (neg false) (mots (list 0 1))) (record Grand (neg false) (mots (list 0 1))))
0))
(equivalence exact)
(body.high
(if (get a neg)
(if (get b neg) (gr_cmp_abs (get b mots) (get a mots)) -1)
(if (get b neg) 1 (gr_cmp_abs (get a mots) (get b mots)))))
(end node gr_cmp))