Skip to content

Commit b0f6a50

Browse files
committed
C library: implement log2{,f,l} and log10{,f,l}
Follows the same approximation approach as previously taken for log (and logf, logl).
1 parent c81a6a6 commit b0f6a50

File tree

13 files changed

+483
-0
lines changed

13 files changed

+483
-0
lines changed
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <assert.h>
2+
#ifdef _WIN32
3+
# define _USE_MATH_DEFINES
4+
#endif
5+
#include <math.h>
6+
7+
int main()
8+
{
9+
double one = log10(10.0);
10+
assert(one > 0.978 && one < 1.005);
11+
return 0;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--float-overflow-check --nan-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <assert.h>
2+
#ifdef _WIN32
3+
# define _USE_MATH_DEFINES
4+
#endif
5+
#include <math.h>
6+
7+
int main()
8+
{
9+
float one = log10f(10.0f);
10+
assert(one > 0.978f && one < 1.005f);
11+
return 0;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--float-overflow-check --nan-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <assert.h>
2+
#ifdef _WIN32
3+
# define _USE_MATH_DEFINES
4+
#endif
5+
#include <math.h>
6+
7+
int main()
8+
{
9+
long double one = log10l(10.0l);
10+
assert(one > 0.978l && one < 1.005l);
11+
return 0;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--float-overflow-check --nan-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <assert.h>
2+
#ifdef _WIN32
3+
# define _USE_MATH_DEFINES
4+
#endif
5+
#include <math.h>
6+
7+
int main()
8+
{
9+
double one = log2(2.0);
10+
assert(one > 0.999 && one < 1.087);
11+
return 0;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--float-overflow-check --nan-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <assert.h>
2+
#ifdef _WIN32
3+
# define _USE_MATH_DEFINES
4+
#endif
5+
#include <math.h>
6+
7+
int main()
8+
{
9+
float one = log2f(2.0f);
10+
assert(one > 0.999f && one < 1.087f);
11+
return 0;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--float-overflow-check --nan-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <assert.h>
2+
#ifdef _WIN32
3+
# define _USE_MATH_DEFINES
4+
#endif
5+
#include <math.h>
6+
7+
int main()
8+
{
9+
long double one = log2l(2.0l);
10+
assert(one > 0.999l && one < 1.087l);
11+
return 0;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--float-overflow-check --nan-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

0 commit comments

Comments
 (0)