Processing math: 100%
C-Programmierung

Mathematische Funktionen

Funktionen als Schnittstelle | | Lokale Variablen

Die Headerdatei <math.h> enthält folgende mathematische und trigonometrische Funktionen und Definitionen:

  • double sqrt(double x) : Quadratwurzel von x, x
  • double pow(double x, double y) : “hoch”, xy
  • double exp(double x) : “e hoch”, ex
  • double sin(double x) : “Sinus”, sinx
  • double cos(double x) : “Cosinus”, cosx
  • double tan(double x) : “Tangens”, tanx
  • double fabs(double x) : “Betrag”, |x|
  • double floor(double x) : “größte Ganzzahl nicht größer als x”, x
  • double ceil(double x) : “kleinste Ganzzahl nicht kleiner als x”, x
  • M_PI : 3.14159265358979323846264338327950288 = π
  • M_SQRT2 : 1.41421356237309504880168872420969808 = 2
  • MAXFLOAT : 3.40282346638528860e+38
  • NAN : Not-A-Number

Beispiel der Wurzelberechnung:

#include <math.h>

double x=10,x2;
x2=sqrt(x);

Rest bei Floating-Point-Division:

double x=2.5,d=0.3,r;
r=x-floor(x/d)*d;


Funktionen als Schnittstelle | | Lokale Variablen

Options: