瀏覽代碼

fixed some bugs, added flt_umin

ceriel 35 年之前
父節點
當前提交
fabf440d6c

+ 1 - 0
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

+ 3 - 2
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

+ 11 - 2
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

+ 5 - 3
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++);
 }

+ 17 - 0
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;
+}