projects
/
tools.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
e422fd0ce216147856f5ed2ddc3ee4871e1f85c2
[tools.git]
/
math
/
round.c
1
#include <jh.h>
2
#include <math.h>
3
4
int main(int argc, char **argv) {
5
if (argc != 2) xperror("invocation: round <target>", 0);
6
double target = strtod(argv[1], NULL);
7
char line[128];
8
while (fgets(line, sizeof(line), stdin)) {
9
double n = strtod(line, NULL);
10
double quot = n / target;
11
quot = round(quot);
12
n = quot * target;
13
printf("%f\n", n);
14
}
15
return 0;
16
}