From fc00f29076aa8171dd238d1d70607ee6abbbba7a Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Tue, 12 Nov 2013 23:50:04 +0100 Subject: Improvemenet of pow2 (suggested by T.Bourke) --- csim/util.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'csim') diff --git a/csim/util.c b/csim/util.c index a09e959..ef0ae32 100644 --- a/csim/util.c +++ b/csim/util.c @@ -10,10 +10,7 @@ #include "sim.h" int pow2(int exp) { - if (exp == 0) return 1; - if (exp == 1) return 2; - int k = pow2(exp / 2); - return (exp % 2 == 0 ? k * k : 2 * k * k); + return (1 << exp); } t_value read_bool(FILE *stream, t_value *mask) { -- cgit v1.2.3