Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Merge pull request #8 from SamuelSarle/master

Implemented the <math.h> ldexp() function and enhanced pow().
  • Loading branch information
Arto Bendiken
Arto Bendiken committed Oct 5, 2017
2 parents 77ddc28 + e99b64e commit 9e560557e497e5fd04094b1a6dce4f2186cca2a3
Showing with 28 additions and 3 deletions.
  1. +18 −0 src/math/ldexp.c
  2. +10 −3 src/math/pow.c
@@ -0,0 +1,18 @@
/* This is free and unencumbered software released into the public domain. */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

/**
* @date 2017-10-04
* @author Samuel Sarle
* @see http://libc11.org/math/ldexp.html
*/

#include <math.h> //For pow()

double
ldexp(const double x, const long long y) {
return x * pow(2, y);
}
@@ -13,9 +13,16 @@
double
pow(const double x, const double y) {
double z = 1;
for (unsigned long long i = 0; i < y; i++) {
z *= x;
if (y > 0) {
for (unsigned long long i = 0; i < y; i++) {
z *= x;
}
}
if (y < 0 && x != 0) {
for (long long i = 0; i > y; i--) {
z /= x;
}
}
return z;
}

}

0 comments on commit 9e56055

Please sign in to comment.
You can’t perform that action at this time.