From 53ce9da82717aeb893a8be7f85037fd8bd271d91 Mon Sep 17 00:00:00 2001 From: ceriel Date: Fri, 28 Jul 1989 14:13:39 +0000 Subject: [PATCH] fixed some bugs, added flt_umin --- modules/src/flt_arith/.distr | 1 + modules/src/flt_arith/Makefile | 5 +++-- modules/src/flt_arith/flt_arith.3 | 13 +++++++++++-- modules/src/flt_arith/flt_str2fl.c | 8 +++++--- modules/src/flt_arith/flt_umin.c | 17 +++++++++++++++++ 5 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 modules/src/flt_arith/flt_umin.c diff --git a/modules/src/flt_arith/.distr b/modules/src/flt_arith/.distr index c8ef39c17..ff15ca61e 100644 --- a/modules/src/flt_arith/.distr +++ b/modules/src/flt_arith/.distr @@ -12,6 +12,7 @@ flt_modf.c flt_mul.c flt_nrm.c flt_str2fl.c +flt_umin.c misc.h ucmp.c flt_arith.3 diff --git a/modules/src/flt_arith/Makefile b/modules/src/flt_arith/Makefile index 3efb70b4b..8a8eeb288 100644 --- a/modules/src/flt_arith/Makefile +++ b/modules/src/flt_arith/Makefile @@ -13,11 +13,11 @@ LIBFLT = libflt.$(LIBSUF) SRC = b64_add.c flt_ar2flt.c flt_div.c flt_nrm.c b64_sft.c flt_chk.c \ flt_flt2ar.c flt_str2fl.c flt_add.c flt_cmp.c flt_mul.c ucmp.c \ - flt_modf.c + flt_modf.c flt_umin.c OBJ = b64_add.$(SUF) flt_ar2flt.$(SUF) flt_div.$(SUF) flt_nrm.$(SUF) \ b64_sft.$(SUF) flt_chk.$(SUF) flt_flt2ar.$(SUF) flt_str2fl.$(SUF) \ flt_add.$(SUF) flt_cmp.$(SUF) flt_mul.$(SUF) ucmp.$(SUF) \ - flt_modf.$(SUF) + flt_modf.$(SUF) flt_umin.$(SUF) .SUFFIXES: .$(SUF) .c.$(SUF): @@ -65,4 +65,5 @@ flt_add.$(SUF): misc.h flt_arith.h flt_cmp.$(SUF): misc.h flt_arith.h flt_mul.$(SUF): misc.h flt_arith.h flt_modf.$(SUF): misc.h flt_arith.h +flt_umin.$(SUF): misc.h ucmp.$(SUF): misc.h flt_arith.h diff --git a/modules/src/flt_arith/flt_arith.3 b/modules/src/flt_arith/flt_arith.3 index 8deaef5e8..dfe27db52 100644 --- a/modules/src/flt_arith/flt_arith.3 +++ b/modules/src/flt_arith/flt_arith.3 @@ -38,13 +38,16 @@ extern int flt_status; .B flt_div(e1, e2, e3) .B flt_arith *e1, *e2, *e3; .PP +.B flt_umin(e) +.B flt_arith *e; +.PP .B flt_modf(e1, intpart, fractpart) .B flt_arith *e1, *intpart, *fractpart; .PP .B int flt_cmp(e1, e2) .B flt_arith *e1, *e2; .PP -.B int flt_str2flt(s, e) +.B flt_str2flt(s, e) .B char *s; .B flt_arith *e; .PP @@ -111,6 +114,12 @@ by the one indicated by and stores the result indirectly through .IR e3 . .PP +.B flt_umin +negates the number indicated by +.I e +and stores the result indirectly through +.IR e . +.PP .B flt_modf splits the number indicated by .I e @@ -176,7 +185,7 @@ characters are stored. .B flt_arith2flt converts the number .I n -to the floating point format use in this package and returns the result +to the floating point format used in this package and returns the result in .IR e . .PP diff --git a/modules/src/flt_arith/flt_str2fl.c b/modules/src/flt_arith/flt_str2fl.c index 22e888aaf..bc178a131 100644 --- a/modules/src/flt_arith/flt_str2fl.c +++ b/modules/src/flt_arith/flt_str2fl.c @@ -402,9 +402,11 @@ flt_flt2str(e, buf, bufsize) register char *s1; char Xbuf[NDIG+12]; register char *s = Xbuf; + flt_arith e1; + e1 = *e; flt_status = 0; - s1 = flt_ecvt(e,NDIG,&dp,&sign); + s1 = flt_ecvt(&e1,NDIG,&dp,&sign); if (sign) *s++ = '-'; *s++ = *s1++; @@ -439,6 +441,6 @@ flt_flt2str(e, buf, bufsize) s = Xbuf; s1 = buf; do { - *s1++ = *s++; - } while (*s); + *s1++ = *s; + } while (*s++); } diff --git a/modules/src/flt_arith/flt_umin.c b/modules/src/flt_arith/flt_umin.c new file mode 100644 index 000000000..f82c971d3 --- /dev/null +++ b/modules/src/flt_arith/flt_umin.c @@ -0,0 +1,17 @@ +/* + (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. + See the copyright notice in the ACK home directory, in the file "Copyright". +*/ + +/* $Header$ */ + +#include "misc.h" + +flt_umin(e) + flt_arith *e; +{ + /* Unary minus + */ + flt_status = 0; + e->flt_sign = ! e->flt_sign; +}