summary refs log tree commit diff
path: root/bin
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
commit51ee06fc5f2383c64e3afdce68ebfe49625ac7e4 (patch)
treec75f9da234ba2d30cc72dd7c187d60ed5136c415 /bin
parentHighlight yacc and lex files as C (diff)
downloadsrc-51ee06fc5f2383c64e3afdce68ebfe49625ac7e4.tar.gz
src-51ee06fc5f2383c64e3afdce68ebfe49625ac7e4.zip
Add T suffix in bit
Diffstat (limited to 'bin')
-rw-r--r--bin/bit.y7
1 files changed, 5 insertions, 2 deletions
diff --git a/bin/bit.y b/bin/bit.y
index 4bf8e2d0..8e9786da 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);