andrewt0301 / hse-acos-course

Materials for the "Computer Architecture and Operating Systems" course taught at Faculty of Computer Science of Higher School of Economics
https://andrewt0301.github.io/hse-acos-course/
Apache License 2.0
32 stars 27 forks source link

OS Test Note #27

Open andrewt0301 opened 1 year ago

andrewt0301 commented 1 year ago

Powering a negative number into a non-integer power can result in NaN:

andrewt@LAPTOP-5GPL0IVV:~/src$ cat test.c
#include <math.h>
#include <stdio.h>

int main() {
   printf("x = %f\n", pow(-7, 1.23));
   return 0;
}
andrewt@LAPTOP-5GPL0IVV:~/src$ gcc test.c -o test -lm
andrewt@LAPTOP-5GPL0IVV:~/src$ ./test
x = -nan

We consider it is OK.