-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexact_float.c
More file actions
54 lines (44 loc) · 982 Bytes
/
exact_float.c
File metadata and controls
54 lines (44 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* =====================================================================================
*
* Filename: exact_float.c
*
* Description: 精确表达浮点数
*
* Version: 1.0
* Created: 04/12/2017 18:20:25
* Revision: none
* Compiler: gcc
*
* Author: YOUR NAME (),
* Organization:
*
* =====================================================================================
*/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int n, m;
int i, j, k;
n = atoi(argv[1]);
m = atoi(argv[2]);
printf("n %d, m %d\n", n, m);
printf("%d.", n / m);
n = n % m;
n = n * 10;
if (n == 0)
printf("0");
else {
i = 0;
while (1) {
printf("%d", n / m);
n = n % m;
n = n * 10;
i ++;
if (i >= 100)
break;
}
}
printf("\n");
return 0L;
}