From f157389255373ae0067afb097aa3c56a1d98a50b Mon Sep 17 00:00:00 2001 From: fdai7848 Date: Mon, 29 Jan 2024 10:39:26 +0100 Subject: [PATCH] add support for negative exponents --- src/exponent.c | 8 ++++++++ src/exponent.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/exponent.c b/src/exponent.c index ca2438f..00a5e39 100644 --- a/src/exponent.c +++ b/src/exponent.c @@ -10,4 +10,12 @@ int expI(unsigned int e, int num){ } return prod; } +} + +float expIN(int e, int num){ + if(e>0){ + return (float) expI(e, num); + }else{ + return 1.0 / (float) expI(e, num); + } } \ No newline at end of file diff --git a/src/exponent.h b/src/exponent.h index 1fea7aa..6963b46 100644 --- a/src/exponent.h +++ b/src/exponent.h @@ -2,5 +2,6 @@ #define EXPONENT_H int expI(unsigned int e, int num); +float expIN(int e, int num); #endif // exponent.h \ No newline at end of file