42 return xdiv(100 * part, whole);
48 return (
int) rint(
xpercent(part, whole));
53xdiv(
double nom,
double denom)
55 return (denom != 0.0) ? nom / denom : -1.0;
63 snprintf(buf,
sizeof(buf),
"%d", num);
72 snprintf(buf,
sizeof(buf),
"%" PRId64, num);
80 g->
bytes &= (1 << 30) - 1;
86 return ((
double) g->
gb) * ((
double) (1 << 30)) + ((
double) g->
bytes);
95 snprintf(buf, buf_size,
"%.2f MB", value / 1e6);
96 else if (value < 1e12)
97 snprintf(buf, buf_size,
"%.3f GB", value / 1e9);
99 snprintf(buf, buf_size,
"%.4f TB", value / 1e12);
110#define max_cc_calls 5
111 typedef char GbBuf[32];
113 static int call_id = 0;
115 char *buf = bufs[call_id++];
122 snprintf(buf,
sizeof(GbBuf),
"%.2f MB", value / 1e6);
123 else if (value < 1e12)
124 snprintf(buf,
sizeof(GbBuf),
"%.2f GB", value / 1e9);
126 snprintf(buf,
sizeof(GbBuf),
"%.2f TB", value / 1e12);
134unsigned int RoundTo(
const unsigned int num,
const unsigned int what)
136 return what * ((num + what -1)/what);
const char * gb_to_str(const gb_t *g)
double xpercent(double part, double whole)
double xdiv(double nom, double denom)
unsigned int RoundTo(const unsigned int num, const unsigned int what)
const char * xitoa(int num)
double gb_to_double(const gb_t *g)
const char * double_to_str(char *buf, int buf_size, double value)
int xpercentInt(double part, double whole)
const char * xint64toa(int64_t num)