0

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?

Marco Bonelli
  • 55,971
  • 20
  • 106
  • 115
  • A couple of things: 1) if you found no kernel code that does a generic power operation, have you wondered why? 2) are you sure you cannot rewrite 2^20 in some other way...? Hint: bit shifts. - With this said, look at the duplicate linked above if you really need to write a generic "2 to the power of N" or [here](https://stackoverflow.com/q/101439/3889449) for a generic "X to the power of Y" function. – Marco Bonelli Nov 27 '21 at 13:44
  • You can't use any floating point functions in the kernel, because FPU registers are not saved during kernel calls. – stark Nov 27 '21 at 15:41

0 Answers0