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.
You are viewing an older revision! See the latest version
Mathematische Funktionen
Eigentlich nicht zu C selbst gehören die folgenden mathematischen Funktionen. Da sie aber zumindest teilweise sehr nützlich sind und in Form einer Bibliothek bei jedem Compiler beiliegen sollten, wollen wir sie hier vorstellen. Um sie zu nutzen muss man folgende Zeile in ein Programm aufnehmen:
#include <math.h>
Beispiel:
Mathe-Beispiel
#include "mbed.h"
#include <stdio.h> /* printf */
#include <math.h> /* cos */
#define PI 3.14159265
int main ()
{
double param, result, x=2.0;
param = 60.0;
result = cos ( param * PI / 180.0 );
printf ("Der Kosinus von %f Grad ist %f.\n", param, result );
printf("2^2 = %f\n", pow(x, 2));
printf("2^2 = %d\n", (int) pow(x, 2)); // Typecast von Float auf Integer
return 0;
}