summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorbiouman <biouman>2001-05-01 12:08:10 +0000
committerbiouman <biouman>2001-05-01 12:08:10 +0000
commit78dcc3729881bb6b3937da195bc070ca96cb049b (patch)
tree147429ecf5a9419745d5496cb011d0cc33a22532 /lib
parent655f3b2663b9909656b896cf47ad949b4e9644a8 (diff)
*** empty log message ***
Diffstat (limited to 'lib')
-rw-r--r--lib/pile.c8
-rw-r--r--lib/scalaires.c37
2 files changed, 39 insertions, 6 deletions
diff --git a/lib/pile.c b/lib/pile.c
index a7d8d47..10991fc 100644
--- a/lib/pile.c
+++ b/lib/pile.c
@@ -280,10 +280,10 @@ void act_pile(int func)
ply_destruct(operande2.poly);
ply_destruct(operande1.poly);
} else {
- exception(1, _("act_pile: OP_EXP invalid arguments"));
+ exception(1, _("act_pile: OP_EXP invalid power"));
}
} else {
- exception(1, _("act_pile: OP_EXP invalid arguments"));
+ exception(1, _("act_pile: OP_EXP empty polynom"));
}
} else {
exception(1, _("act_pile: OP_EXP invalid arguments"));
@@ -350,10 +350,10 @@ void act_pile(int func)
ply_destruct(operande1.poly);
ply_destruct(operande2.poly);
} else {
- exception(1, _("act_pile: OP_FUNC_CALL invalid arguments"));
+ exception(1, _("act_pile: OP_FUNC_CALL incorrect value for 2nd arg"));
}
} else {
- exception(1, _("act_pile: OP_FUNC_CALL invalid arguments"));
+ exception(1, _("act_pile: OP_FUNC_CALL arg2 is an empty polynom"));
}
} else {
exception(1, _("act_pile: OP_FUNC_CALL invalid arguments"));
diff --git a/lib/scalaires.c b/lib/scalaires.c
index ab97084..d2f24fb 100644
--- a/lib/scalaires.c
+++ b/lib/scalaires.c
@@ -12,8 +12,9 @@
#define _(x) x
#endif
-
#define PRECISION 1E6
+typedisplay display=DEC;
+
static int pgcd(int a, int b)
{
if (a < b)
@@ -54,7 +55,7 @@ rationnel rat_constr(int num, int denom)
temp.num = sgnnum * sgndenom * num / pgcd(num, denom);
temp.denom = denom / pgcd(num, denom);
} else {
- exception(1, _("rat_constr: division by zero"));
+ exception(2, _("rat_constr: division by zero"));
}
return temp;
@@ -113,3 +114,35 @@ rationnel rat_division(rationnel rat1, rationnel rat2)
return rat_constr(rat1.num * rat2.denom, rat1.denom * rat2.num);
}
+
+char *rat_to_string(rationnel rat)
+{
+ char resultat[128];
+ char temp[64];
+
+ if (rat.num<0) {
+ rat.num=-rat.num;
+ strcat(resultat,"-");
+ } else {
+ strcat(resultat,"+");
+ }
+
+ switch(display) {
+ case DEC:
+ sprintf(temp,"%d/%d", rat.num, rat.denom);
+ break;
+ case HEX:
+ sprintf(temp,"%x/%x", rat.num, rat.denom);
+ break;
+ case OCT:
+ sprintf(temp,"%o/%o", rat.num, rat.denom);
+ break;
+ case FLT:
+ sprintf(temp,"%f", rat_to_double(rat));
+ break;
+ }
+
+ strcat(resultat, temp);
+ return resultat;
+
+}