1 |
#define EXTERN extern |
2 |
|
3 |
#include "pcwin.h" |
4 |
#include "pcmod.h" |
5 |
|
6 |
void numeral(int number, char *astring, int size) |
7 |
{ |
8 |
int multi,length,minsize,million,hthou,tthou; |
9 |
int thou, hun,tens,ones; |
10 |
int right, negative; |
11 |
char bstring[4]; |
12 |
|
13 |
if (size == 0) |
14 |
{ |
15 |
right = FALSE; |
16 |
size = 1; |
17 |
} else |
18 |
right = TRUE; |
19 |
|
20 |
minsize = size; |
21 |
length = size; |
22 |
|
23 |
if (number > 0) |
24 |
negative = FALSE; |
25 |
else |
26 |
{ |
27 |
negative = TRUE; |
28 |
number = -number; |
29 |
} |
30 |
million = number/1000000; |
31 |
multi = 1000000*million; |
32 |
hthou = (number-multi)/100000; |
33 |
multi = multi + 100000*hthou; |
34 |
tthou = (number-multi)/10000; |
35 |
multi = multi + 10000*tthou; |
36 |
thou = (number-multi)/1000; |
37 |
multi = multi + 1000*thou; |
38 |
hun = (number-multi)/100; |
39 |
multi = multi + 100*hun; |
40 |
tens = (number-multi)/10; |
41 |
multi = multi + 10*tens; |
42 |
ones = number - multi; |
43 |
|
44 |
if (million != 0) |
45 |
size = 7; |
46 |
else if (hthou != 0) |
47 |
size = 6; |
48 |
else if (tthou != 0) |
49 |
size = 5; |
50 |
else if (thou != 0) |
51 |
size = 4; |
52 |
else if (hun != 0) |
53 |
size = 3; |
54 |
else if (tens != 0) |
55 |
size = 2; |
56 |
else |
57 |
size = 1; |
58 |
|
59 |
if ( length < size) |
60 |
size = length; |
61 |
if ( minsize > size) |
62 |
size = minsize; |
63 |
|
64 |
sprintf(bstring,"%d",number); |
65 |
size = strlen(bstring); |
66 |
|
67 |
if (size == 3) |
68 |
{ |
69 |
astring[0] = bstring[0]; |
70 |
astring[1] = bstring[1]; |
71 |
astring[2] = bstring[2]; |
72 |
astring[3] = '\0'; |
73 |
} else if (size == 2) |
74 |
{ |
75 |
bstring[2] = ' '; |
76 |
astring[0] = bstring[2]; |
77 |
astring[1] = bstring[0]; |
78 |
astring[2] = bstring[1]; |
79 |
astring[3] = '\0'; |
80 |
} else if (size == 1) |
81 |
{ |
82 |
bstring[2] = ' '; |
83 |
astring[0] = bstring[2]; |
84 |
astring[1] = bstring[2]; |
85 |
astring[2] = bstring[0]; |
86 |
astring[3] = '\0'; |
87 |
} |
88 |
|
89 |
} |