いろいろなテクニック.Nucleo と DISCO-F746 用.
Dependencies: Array_Matrix mbed
Diff: MyMath.hpp
- Revision:
- 0:bb939e0bc6e2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MyMath.hpp Sun Oct 15 11:41:48 2017 +0000 @@ -0,0 +1,37 @@ +//-------------------------------------------------- +// 算術関数のテスト +// log10f(), fabsf(), floorf(), min(), max() +//-------------------------------------------------- + +#include "mbed.h" +//#include <cmath> // このインクルード文は不要 +#include <algorithm> // min(), max() を使う場合は <algorithm> をインクルードすること + +void MyMath() +{ + printf("\r\nStart of \"MyMath\"\r\n"); + + float x1 = log10f(100.0f); + printf("log10(100) = %f\r\n", x1); + + x1 = log10f(2.0f); + printf("log10(2) = %f\r\n", x1); + + x1 = fabsf(-0.123f); + printf("|x1| = %f\r\n", x1); + + x1 = floorf(2.1f); + printf("floor(2.1) = %f\r\n", x1); + + // min(), max() を使う場合は <algorithm> をインクルードすること + x1 = min(0.1f, -2.4f); + printf("min(0.1, -2.4) = %f\r\n", x1); + float x2 = max(0.1f, -2.4f); + printf("max(0.1, -2.4) = %f\r\n", x2); + + int x3 = max(1, 2); + printf("max(1, 2) = %d\r\n", x3); + + printf("End of \"MyMath\"\r\n"); +} +