Skip to content

Commit

Permalink
Add powf to math.h
Browse files Browse the repository at this point in the history
  • Loading branch information
maximecb committed Oct 1, 2023
1 parent 4c52f51 commit 35c5434
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ncc/include/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 3 additions & 0 deletions ncc/tests/floats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 35c5434

Please sign in to comment.