Commit graph

11 commits

Author SHA1 Message Date
carl
add131b6f9 ANSI C conversion of code, rename some parameters to better names and adapt man page accordingly. 2019-05-11 00:56:13 +08:00
George Koehler
3bb41d3910 Switch flt_mantissa fields from long to uint32_t.
This seems to fix an error when flt_arith converts a literal
double-precision float to IEEE format.  For example, 0.5 and 0.75 got
converted to slightly below their correct values.

My host gcc for amd64 has 64-bit long, but flt_arith needs only 32
bits.  The code (at least flt_add.c) can make 32-bit overflows.  Such
overflows would set the higher bits of a 64-bit long, which might
cause problems later.

I need to use uint32_t and not int32_t because the code still uses
long, and the sign extension from int32_t to long would cause
problems.  The mantissa represents a value in [0, 2) that can't be
negative, so unsigned type is better.  Also, signed overflow is
undefined behavior in C, so flt_add.c better make overflows with
uint32_t and not int32_t.

This commit doesn't touch lang/cem/libcc.ansi/stdlib/ext_fmt.h which
continues to use unsigned long for its mantissa fields.
2016-11-05 17:00:24 -04:00
George Koehler
5c62ec2d8f Assume ANSI C in modules/src/flt_arith
Remove the #include "ansi.h" and always use the prototypes.
2016-11-05 16:24:18 -04:00
ceriel
5c83e7dbb5 Header --> Id 1994-06-24 11:31:16 +00:00
ceriel
11d4fdf6e0 Added prototyping stuff 1993-11-10 11:14:28 +00:00
ceriel
ab8dcfa134 ANSI C fixes 1993-10-21 12:50:58 +00:00
ceriel
a0acff4f4c minor change: give anonymous struct a name 1992-02-26 15:46:44 +00:00
ceriel
89887ef6b0 made more acceptable for ANSI C 1991-11-26 14:39:52 +00:00
ceriel
3e194345cf Added #define for buffer size needed for flt_flt2str() 1989-07-31 13:05:51 +00:00
ceriel
1e9c82d6e5 made to work, and added the b64 shift routines to the interface 1989-07-11 09:15:17 +00:00
ceriel
c20a2155fa Initial revision 1989-07-10 11:17:19 +00:00