From bab238d58bee686d66a149d6506d133f4b7031bf Mon Sep 17 00:00:00 2001 From: mfranz Date: Mon, 22 Dec 2008 01:50:48 +0000 Subject: [PATCH] string(): make zero padding work if arg is 0 --- Nasal/bits.nas | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Nasal/bits.nas b/Nasal/bits.nas index 042dfd309..0af9bd242 100644 --- a/Nasal/bits.nas +++ b/Nasal/bits.nas @@ -29,9 +29,7 @@ var switch = func(n, b, v) n - (test(n, b) - !!v) * bit[b]; # returns number as bit string, zero-padded to digits: # bits.string(6) -> "110" # bits.string(6, 8) -> "00000110" -var string = func(n, len = 0) { - if (!n) - return '0'; +var string = func(n, len = 1) { var s = ""; while (n) { var v = int(n / 2);