commit 443a2adf892cd424d51733a0ee2ec44164479f80
parent 7efd0ff2e01c72c2997535545ba5b62931b0e110
Author: z3bra <willyatmailoodotorg>
Date: Fri, 29 Apr 2016 22:32:01 +0200
Minor style update/refactoring
Diffstat:
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/human.c b/human.c
@@ -21,7 +21,7 @@
#include <string.h>
#include "arg.h"
-#define EXA 1152921504606846976
+#define EXA 1152921504606846976
#define PETA 1125899906842624
#define TERA 1099511627776
#define GIGA 1073741824
@@ -74,7 +74,7 @@ int getscale()
*/
char factorize (double number)
{
- return number >= EXA ? 'E' :
+ return number >= EXA ? 'E' :
number >= PETA ? 'P' :
number >= TERA ? 'T' :
number >= GIGA ? 'G' :
@@ -139,12 +139,11 @@ int human(char* s, char fac)
fac = fac > 0 ? fac : factorize(number);
/* actually print the result, isn't that what we're here for after all ? */
- if (fac == 'B' || fac == '\0') {
- printf("%.*f\n", getscale(), humanize(number, fac));
- }
- else {
- printf("%.*f%c\n", getscale(), humanize(number, fac), fac);
+ printf("%.*f", getscale(), humanize(number, fac));
+ if (fac && fac != 'B') {
+ putchar(fac);
}
+ putchar('\n');
return 0;
}