Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Array_Matrix mbed
MyMath.hpp
- Committer:
- MikamiUitOpen
- Date:
- 2019-04-10
- Revision:
- 1:bbb9f0c3e523
- Parent:
- 0:bb939e0bc6e2
File content as of revision 1:bbb9f0c3e523:
//--------------------------------------------------
// 算術関数のテスト
// 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");
}