Code for @Justin's answer. Please note that this is very easy to generalize.
#include <math.h> #include <stdio.h> int main(void) { int i; double numbers[] = { 1.82, 0.3, 0.2, 0.5, 10000000000.849, }; for (i = 0; i < sizeof(numbers)/sizeof(numbers[0]); ++i) { double scaled = ceil(20 * numbers[i]); printf("%.2f\n", scaled/20.0); } return 0; }
Sinan Ünür
source share