Last active
September 18, 2023 09:10
-
-
Save lupyuen/63bd510d7e45ceebe7443c78ed31c6c8 to your computer and use it in GitHub Desktop.
Test Math Functions on NuttX for RISC-V JH7110 (NuttX Kernel Mode). See https://gist.github.com/lupyuen/9bdb1f5478318631d0480f03f6041d83
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test Math Functions on NuttX for RISC-V JH7110 (NuttX Kernel Mode) | |
// Paste the code below into apps/examples/hello/hello_main.c | |
// See the ELF Symbols: https://gist.github.com/lupyuen/24f440e14349b2ed56d1784867156378 | |
#include <nuttx/config.h> | |
#include <stdio.h> | |
#include <math.h> | |
int main(int argc, FAR char *argv[]) | |
{ | |
printf("acos(0.987)=%f\n", acos(0.987)); | |
printf("asin(0.987)=%f\n", asin(0.987)); | |
printf("atan(0.987)=%f\n", atan(0.987)); | |
printf("atan2(0.987, 0.987)=%f\n", atan2(0.987, 0.987)); | |
printf("ceil(0.987)=%f\n", ceil(0.987)); | |
printf("cos(0.987)=%f\n", cos(0.987)); | |
printf("exp(0.987)=%f\n", exp(0.987)); | |
printf("floor(0.987)=%f\n", floor(0.987)); | |
printf("log(0.987)=%f\n", log(0.987)); | |
printf("pow(0.987, 0.987)=%f\n", pow(0.987, 0.987)); | |
printf("sin(0.987)=%f\n", sin(0.987)); | |
printf("sqrt(0.987)=%f\n", sqrt(0.987)); | |
printf("tan(0.987)=%f\n", tan(0.987)); | |
return 0; | |
} | |
/* Expected Output: | |
nsh> hello | |
acos(0.987)=0.161420 | |
asin(0.987)=1.409376 | |
atan(0.987)=0.778856 | |
atan2(0.987, 0.987)=0.785398 | |
ceil(0.987)=1.000000 | |
cos(0.987)=0.551195 | |
exp(0.987)=2.683173 | |
floor(0.987)=0.000000 | |
log(0.987)=-0.013085 | |
pow(0.987, 0.987)=0.987168 | |
sin(0.987)=0.834376 | |
sqrt(0.987)=0.993479 | |
tan(0.987)=1.513757 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment