From 35c5434a19ef6ea9157427b11f80d6e2286b1245 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert Date: Sat, 30 Sep 2023 22:46:45 -0400 Subject: [PATCH] Add powf to math.h --- ncc/include/math.h | 11 ++++++----- ncc/tests/floats.c | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ncc/include/math.h b/ncc/include/math.h index 995f03d..8d3c0f4 100644 --- a/ncc/include/math.h +++ b/ncc/include/math.h @@ -6,11 +6,12 @@ // Here we use macros for performance because // ncc doesn't yet support inline functions -#define sinf(__f) (asm (__f) -> float { sin_f32; }) -#define cosf(__f) (asm (__f) -> float { cos_f32; }) -#define tanf(__f) (asm (__f) -> float { tan_f32; }) -#define atanf(__f) (asm (__f) -> float { atans_f32; }) -#define sqrtf(__f) (asm (__f) -> float { sqrt_f32; }) +#define sinf(f) (asm (f) -> float { sin_f32; }) +#define cosf(f) (asm (f) -> float { cos_f32; }) +#define tanf(f) (asm (f) -> float { tan_f32; }) +#define atanf(f) (asm (f) -> float { atans_f32; }) +#define powf(x, y) (asm (x, y) -> float { pow_f32; }) +#define sqrtf(f) (asm (f) -> float { sqrt_f32; }) float floorf(float x) { diff --git a/ncc/tests/floats.c b/ncc/tests/floats.c index 63e7928..6648c98 100644 --- a/ncc/tests/floats.c +++ b/ncc/tests/floats.c @@ -34,6 +34,9 @@ int main() assert(2.0f * 3.0f == 6.0f); assert(6.0f / 2.0f == 3.0f); + assert(powf(0.0f, 1.0f) == 0.0f); + assert(powf(1.0f, 2.0f) == 1.0f); + assert(powf(2.0f, 3.0f) == 8.0f); assert(sqrtf(0.0f) == 0.0f); assert(sqrtf(4.0f) == 2.0f); assert(sinf(0.0f) == 0.0f);