How can I use pow function in kernel space? [duplicate] - c

This question already has answers here:
2 to the power of N in C without pow
(2 answers)
The most efficient way to implement an integer based power function pow(int, int)
(21 answers)
Closed 1 year ago.
I want to do a pretty simple calculation: 2^20, but I don't have the library math.h.
How can I do it in the kernel space?

Related

How do I raise a number by another number (num1^num2) [duplicate]

This question already has answers here:
The most efficient way to implement an integer based power function pow(int, int)
(21 answers)
How to raise to the power of [duplicate]
(5 answers)
Closed 8 months ago.
The community reviewed whether to reopen this question 8 months ago and left it closed:
Original close reason(s) were not resolved
This is my code. I get 3^2=1. I have included the math library.
case '^':
printf("The result is %d\n",(num1^num2));
break;

Sqrt function working in c [duplicate]

This question already has answers here:
How is the square root function implemented? [closed]
(15 answers)
Closed 8 years ago.
How does sqrt function really work ? Does it go by any logical theorem to get the result.
Is there any way i can access the code of libarary function such as sqrt?
You can download the source code from the libc, which is open source: http://www.gnu.org/software/libc/download.html

How is the function "sin" realized? [duplicate]

This question already has answers here:
How does C compute sin() and other math functions?
(22 answers)
Closed 9 years ago.
Anybody can explain or show how is the function "sin" (or "sinf", "sinl") realized in C.
Intuition suggests that it should be somewhere in the math.h but I did not see anything there
There's a couple ways I can think of right off the bat:
Lookup tables
Approximation via Taylor series (which can be easily made accurate to a number of significant digits).

Is `qsort()` really QuickSort? [duplicate]

This question already has answers here:
Quicksort implementation in C?
(1 answer)
What sorting algorithm does qsort use?
(3 answers)
Closed 9 years ago.
Silly question perhaps, but is there any guarantee that the qsort() routine in the C standard library really implements the QuickSort algorithm?
Since there is nothing in the standard that nominates QuickSort specifically, no.

sizeof(function_name) [duplicate]

This question already has answers here:
What does 'sizeof (function name)' return?
(4 answers)
Closed 10 years ago.
I tried sizeof(printf) , sizeof(foobar) etc. where foobar is a user defined function. It returns 1 without any warning or error. Why 1?
The size of functions is not well defined in C, so the value is meaningless.

Resources