From 51a7864b4b789583ea445af47324a9b613336162 Mon Sep 17 00:00:00 2001 From: biouman Date: Mon, 30 Apr 2001 01:21:20 +0000 Subject: *** empty log message *** --- lib/scalaires.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'lib/scalaires.c') diff --git a/lib/scalaires.c b/lib/scalaires.c index b853741..14b3db2 100644 --- a/lib/scalaires.c +++ b/lib/scalaires.c @@ -7,6 +7,12 @@ #include "scalaires.h" #include "exceptions.h" #include +#ifdef HAVE_CONFIG_H +#include "config.h" +#else +#define _(x) x +#endif + #define PRECISION 1E6 static int pgcd(int a, int b) @@ -31,19 +37,25 @@ rationnel rat_constr_zero(void) rationnel rat_constr(int num, int denom) { /* cree une fraction */ rationnel temp; + int sgnnum = 1, sgndenom = 1; + if (num < 0) { + sgnnum = -1; + num = -num; + } + if (denom < 0) { + sgndenom = -1; denom = -denom; - num = -num; } if (!num) { temp.num=0; temp.denom=1; } else if (denom) { - temp.num = num / pgcd(num, denom); + temp.num = sgnnum * sgndenom * num / pgcd(num, denom); temp.denom = denom / pgcd(num, denom); } else { - exception(1,"rat_constr: division par zero"); + exception(1,_("rat_constr: division by zero")); } return temp; -- cgit v1.2.3