summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-05-12 11:31:08 -0400
committerJune McEnroe <june@causal.agency>2019-05-12 12:18:31 -0400
commita07d0e0b9a8e8af4b855018facde4e4b02e54dd4 (patch)
tree4511a7ec9c865f6994cddb30828d06c45bc609d7
parentHighlight yacc and lex files as C (diff)
downloadsrc-a07d0e0b9a8e8af4b855018facde4e4b02e54dd4.tar.gz
src-a07d0e0b9a8e8af4b855018facde4e4b02e54dd4.zip
Add T suffix in bit
Diffstat (limited to '')
-rw-r--r--bin/bit.y7
1 files changed, 5 insertions, 2 deletions
diff --git a/bin/bit.y b/bin/bit.y
index 798103f1..8e816fec 100644
--- a/bin/bit.y
+++ b/bin/bit.y
@@ -54,7 +54,7 @@ static uint64_t get(size_t i) {
 %left '+' '-'
 %left '*' '/' '%'
 %right '~'
-%left 'K' 'M' 'G'
+%left 'K' 'M' 'G' 'T'
 
 %%
 
@@ -72,6 +72,7 @@ expr:
 	| expr 'K' { $$ = $1 << 10; }
 	| expr 'M' { $$ = $1 << 20; }
 	| expr 'G' { $$ = $1 << 30; }
+	| expr 'T' { $$ = $1 << 40; }
 	| '~' expr { $$ = ~$2; }
 	| '-' expr { $$ = -$2; }
 	| expr '*' expr { $$ = $1 * $3; }
@@ -129,7 +130,9 @@ static void print(size_t i) {
 	);
 
 	if (val) {
-		if (!(val & (1 << 30) - 1)) {
+		if (!(val & (1ULL << 40) - 1)) {
+			printf(" %"PRId64"T", val >> 40);
+		} else if (!(val & (1 << 30) - 1)) {
 			printf(" %"PRId64"G", val >> 30);
 		} else if (!(val & (1 << 20) - 1)) {
 			printf(" %"PRId64"M", val >> 20);