From b8c357c667ef0f3b894e6cd039fb495a6ce5254a Mon Sep 17 00:00:00 2001 From: fdai7057 Date: Thu, 2 Feb 2023 10:15:58 +0100 Subject: [PATCH] bug fix: the behaviour of the function power() for 0 to the power of 0 and and for an exponent with the value 0 for any positive base in the range of the data type is not undefined anymore. --- src/stringManipulation.c | 4 ++++ test/test_StringManipulation.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/stringManipulation.c b/src/stringManipulation.c index 228cc8c..8fb83eb 100644 --- a/src/stringManipulation.c +++ b/src/stringManipulation.c @@ -55,12 +55,16 @@ char *to_string(int number) } unsigned int power(unsigned int b, unsigned int n){ + if(b==0&&n==0) return 0; + else if(b>=1&&n==0) return 1; + else{ unsigned int result = 1, ctr = 0; while(ctr