#include #include #include "mcom_runtime/uart.h" // // @description: PI approximation // @parameters : startstep - // endstep - // step - float SuperPi(int startstep, int endstep, float step) { float x; float sum = 0.0; for (; startstep < endstep; startstep++) { x = (startstep - 0.5) * step; sum = sum + 4.0 / (1. + x * x); if(sum < (1 * (startstep + 1))) { return sum; } } sum *= step; return sum; } int core1_task(int n_steps) { char str[128]; float pi = 0; // pi = SuperPi(1, n_steps, 1/(1.0f*n_steps)); sprintf(str, "PI approximation = %.6f \r\n\r\n", pi); uart_puts(0, str); }