vistaでstm32duino その11

#概要

vistaでstm32duinoやってみた。
math、やってみた。

#サンプルコード

```
#include <math.h>

#define PI		  3.14159265
void func0() {
	Serial.print("\nVarious Math Functions\n");
	Serial.print("the abs of -20 is = "); Serial.println(abs(-20));
	Serial.print("the fabs of -12.1 is = "); Serial.println(fabs(-12.1));
	Serial.print("the ceil of 12.1 is = "); Serial.println(ceil(12.1));
	Serial.print("the floor of 20.9 is = "); Serial.println(floor(20.9));
	Serial.print("the fmod of 120 is = "); Serial.println(fmod(120, 5));
	Serial.print("the trunc of -20.02 is = "); Serial.println(trunc(-20.02));
}
void func1() {
	Serial.print("\nExponential, Logarithmic, and Power Functions\n");
	Serial.print("the exp of 4 is = "); Serial.println(exp(4));
	Serial.print("the ldexp of 4 is = "); Serial.println(ldexp(4, 2));
	//Serial.print("the log2 of 1000000 is = "); Serial.println(log2(1000000));
	Serial.print("the log10 of 1000000 is = "); Serial.println(log10(1000000));
	Serial.println("the modf of 8.12345 is = ");
	double x, fractpart, intpart;
	fractpart = modf(8.12345, &intpart);
	Serial.print("	Integral part = "); Serial.println(intpart);
	Serial.print("	Fraction Part = "); Serial.println(modf(8.12345, &intpart));
	Serial.print("the pow of 10 is = "); Serial.println(pow(10, 2));
	Serial.print("the sqrt of 36 is = "); Serial.println(sqrt(36));
}
void func2() {
	Serial.print("\nTrigonometic Functions\n");
	Serial.print("the cos of 16 is = "); Serial.println(cos(16));
	Serial.print("The acos of 0.9 is = degrees "); Serial.println(acos(0.9) * (180.0 / PI));
	Serial.print("the cosh of 16 is = "); Serial.println(cosh(16));
	Serial.print("the sin of 16 is = "); Serial.println(sin(16));
	Serial.print("the sinh of 16 is = "); Serial.println(sinh(16));
	Serial.print("The asin of 0.9 is = degrees "); Serial.println(asin(0.9) * (180.0 / PI));
	Serial.print("the tan of 4 is = "); Serial.println(tan(4));
	Serial.print("the atan of 4 is = "); Serial.println(atan(4));
	Serial.print("the atan2 of 4 is = "); Serial.println(atan2(4, 2));
}
void size() {
	Serial.print("\nSizeof\n");
	Serial.print("Bytes per char:		   "); Serial.println((int) sizeof(char));
	Serial.print("Bytes per unsigned char:  "); Serial.println((int) sizeof(unsigned char));
	Serial.print("Bytes per short:		  "); Serial.println((int) sizeof(short));
	Serial.print("Bytes per unsigned short: "); Serial.println((int) sizeof(unsigned short));
	Serial.print("Bytes per int:			"); Serial.println((int) sizeof(int));
	Serial.print("Bytes per unsigned int:   "); Serial.println((int) sizeof(unsigned int));
	Serial.print("Bytes per long:		   "); Serial.println((int) sizeof(long));
	Serial.print("Bytes per unsigned long:  "); Serial.println((int) sizeof(unsigned long));
	Serial.print("Bytes per size_t:		 "); Serial.println((int) sizeof(size_t));
	Serial.print("Bytes per float:		  "); Serial.println((int) sizeof(float));
	Serial.print("Bytes per double:		 "); Serial.println((int) sizeof(double));
	Serial.print("Bytes per long double:	"); Serial.println((int) sizeof(long double));
	Serial.print("Bytes per pointer:		"); Serial.println((int) sizeof(void *));
}
void setup() {
	Serial.begin(9600);
	while (!Serial) delay(250);
	Serial.print("ok");
	Serial.println();
	size();
	func0();
	func1();
	func2();
}
void loop() {
	delay(5000);
}






```

#結果

```
ok

Sizeof
      Bytes per char:              1
Bytes per unsigned char:  1
Bytes per short:                  2
Bytes per unsigned short: 2
Bytes per int:                  4
Bytes per unsigned int:   4
Bytes per long:            4
Bytes per unsigned long:  4
Bytes per size_t:                4
Bytes per float:                  4
Bytes per double:                8
Bytes per long double:  8
Bytes per pointer:              4

Various Math Functions
                      the abs of -20 is = 20
the fabs of -12.1 is = 12.10
the ceil of 12.1 is = 13.00
the floor of 20.9 is = 20.00
the fmod of 120 is = 0.00
the trunc of -20.02 is = -20.00

Exponential, Logarithmic, and Power Functions
                                             the exp of 4 is = 54.60
the ldexp of 4 is = 16.00
the log10 of 1000000 is = 6.00
the modf of 8.12345 is =
        Integral part = 8.00
        Fraction Part = 0.12
the pow of 10 is = 100.00
the sqrt of 36 is = 6.00

Trigonometic Functions
                      the cos of 16 is = -0.96
The acos of 0.9 is = degrees 25.84
the cosh of 16 is = 4443055.26
the sin of 16 is = -0.29
the sinh of 16 is = 4443055.26
The asin of 0.9 is = degrees 64.16
the tan of 4 is = 1.16
the atan of 4 is = 1.33
the atan2 of 4 is = 1.11


```


以上。