OLD | NEW |
1 /**************************************************************** | 1 /**************************************************************** |
2 * | 2 * |
3 * The author of this software is David M. Gay. | 3 * The author of this software is David M. Gay. |
4 * | 4 * |
5 * Copyright (c) 1991, 1996 by Lucent Technologies. | 5 * Copyright (c) 1991, 1996 by Lucent Technologies. |
6 * | 6 * |
7 * Permission to use, copy, modify, and distribute this software for any | 7 * Permission to use, copy, modify, and distribute this software for any |
8 * purpose without fee is hereby granted, provided that this entire notice | 8 * purpose without fee is hereby granted, provided that this entire notice |
9 * is included in all copies of any software which is or includes a copy | 9 * is included in all copies of any software which is or includes a copy |
10 * or modification of this software and in all copies of the supporting | 10 * or modification of this software and in all copies of the supporting |
11 * documentation for such software. | 11 * documentation for such software. |
12 * | 12 * |
13 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED | 13 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
14 * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY | 14 * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY |
15 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY | 15 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY |
16 * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. | 16 * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
17 * | 17 * |
18 ***************************************************************/ | 18 ***************************************************************/ |
19 | 19 |
20 /* g_fmt(buf,x) stores the closest decimal approximation to x in buf; | 20 /* g_fmt(buf,x) stores the closest decimal approximation to x in buf; |
21 * it suffices to declare buf | 21 * it suffices to declare buf |
22 * char buf[32]; | 22 * char buf[32]; |
23 */ | 23 */ |
24 | 24 |
25 #include "dmg_fp.h" | 25 #include "dmg_fp.h" |
26 | 26 |
27 namespace dmg_fp { | 27 namespace dmg_fp { |
28 | 28 |
29 char * | 29 char * |
30 g_fmt(register char *b, double x) | 30 g_fmt(char *b, double x) |
31 { | 31 { |
32 » register int i, k; | 32 » int i, k; |
33 » register char *s; | 33 » char *s; |
34 int decpt, j, sign; | 34 int decpt, j, sign; |
35 char *b0, *s0, *se; | 35 char *b0, *s0, *se; |
36 | 36 |
37 b0 = b; | 37 b0 = b; |
38 #ifdef IGNORE_ZERO_SIGN | 38 #ifdef IGNORE_ZERO_SIGN |
39 if (!x) { | 39 if (!x) { |
40 *b++ = '0'; | 40 *b++ = '0'; |
41 *b = 0; | 41 *b = 0; |
42 goto done; | 42 goto done; |
43 } | 43 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 done0: | 94 done0: |
95 freedtoa(s0); | 95 freedtoa(s0); |
96 #ifdef IGNORE_ZERO_SIGN | 96 #ifdef IGNORE_ZERO_SIGN |
97 done: | 97 done: |
98 #endif | 98 #endif |
99 return b0; | 99 return b0; |
100 } | 100 } |
101 | 101 |
102 } // namespace dmg_fp | 102 } // namespace dmg_fp |
OLD | NEW |