diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pile.c | 9 | ||||
-rw-r--r-- | lib/scalaires.c | 12 |
2 files changed, 11 insertions, 10 deletions
@@ -48,13 +48,8 @@ void push_pile(char *st) popcontext(); } else if (valid3) { /* il s agit de x */ pushcontext("c est X"); - rat=rat_constr(1, 1); - /*pushcontext("rat construit"); - poly=ply_constr(rat, 0); - pushcontext("poly cstr"); - push_pile_poly(poly); - pushcontext("poly push"); - popcontext();*/ + push_pile_poly(ply_constr(rat_constr(1, 1), 0)); + popcontext(); } else if (valid4) { /* il s agit d une variable */ pushcontext("c est une variable"); push_pile_poly(ply_copy(poly)); diff --git a/lib/scalaires.c b/lib/scalaires.c index f94162a..10c9196 100644 --- a/lib/scalaires.c +++ b/lib/scalaires.c @@ -35,9 +35,15 @@ rationnel rat_constr(int num, int denom) denom = -denom; num = -num; } - - temp.num = num / pgcd(num, denom); - temp.denom = denom / pgcd(num, denom); + if (!num) { + temp.num=0; + temp.denom=1; + } else if (denom) { + temp.num = num / pgcd(num, denom); + temp.denom = denom / pgcd(num, denom); + } else { + exception(1,"rat_constr: division par zero"); + } return temp; } |