Math.h

Math.h

math.h ist eine Header-Datei in der Standard C Library der Programmiersprache C. Sie wurde für mathematische Funktionen entwickelt. Die Programmiersprache C++ benutzt die Funktionen ebenfalls, um die Kompatibilität von C zu C++ zu gewährleisten und deklariert sie in der Header-Datei cmath (dort ohne die Dateinamenserweiterung „.h“ verwendet).

Alle Funktionen, die einen Winkel einlesen oder ausgeben, arbeiten mit Radiant. Die meisten Funktionen arbeiten mit Gleitkommazahlen. Mathematische Funktionen, die mit ganzzahligen Werten (Integer) arbeiten, wie abv, labs, div oder ldiv, sind stattdessen in der Header-Datei stdlib.h vertreten.

Inhaltsverzeichnis

Funktionen bis C95

In den Normen bis einschließlich C95 waren die folgenden Funktionen deklariert.

Name Beschreibung
acos Arkuskosinus
asin Arkussinus
atan Arkustangens, mit einem Argument
atan2 Arkustangens, mit zwei Argumenten
ceil Aufrundungsfunktion
cos Kosinus
cosh Kosinus Hyperbolicus
exp Exponentialfunktion
fabs Betragsfunktion
floor Ganzteilfunktion
fmod Führt die Modulo Funktion für Gleitkommazahlen durch
frexp Teilt eine Gleitkommazahl in Faktor und Potenz mit der Basis 2 auf
ldexp Multipliziert die eingegebene Faktor mit 2 um den Exponent potenziert, f · 2 exp
log Natürlicher Logarithmus
log10 Logarithmus zur Basis 10
modf(x,p) Teilt eine Gleitkommazahl in zwei Zahlen auf vor und nach dem Komma
pow(x,y) Potenziert x mit dem Exponent y, xy
sin Sinus
sinh Sinus Hyperbolicus
sqrt Quadratwurzel
tan Tangens
tanh Tangens Hyperbolicus

C99-Funktionen

Mit der Norm C99 wurde math.h um die folgenden Funktionen erweitert.

Name Beschreibung
acosh Areakosinus Hyperbolicus
asinh Areakosinus Hyperbolicus
atanh Areatangens Hyperbolicus
cbrt Kubikwurzel
copysign(x,y) gibt den Wert von x mit dem Vorzeichen von y zurück
erf Fehlerfunktion
erfc Gibt den Komplementärfehler von x zurück
exp2(x) Potenziert 2 mit x, 2x
expm1(x) Liefert den wert von exp()-1 zurück, ex − 1
fdim(x,y) Positive differenz zwischen x and y, fmax (xy, 0)
fma(x,y,z) Multipliziert und Addiert, (x * y) + z
fmax(x,y) Maximum
fmin(x,y) Minimunm
hypot(x,y) Hypotenuse, sqrt (x2 + y2)
ilogb der Exponent einer Gleitkommazahl wird ein int zurückgegeben
lgamma Gammafunktion
llrint Rundungsfunktion
lrint Rundungsfunktion
llround Rundungsfunktion
lround Rundungsfunktion
log1p(x) Natürlicher Logarithmus von 1 + x
log2 Logarithmus zur Basis 2
logb Liefert den ganzzahligen Exponenten einer Gleitpunktzahl
nan(s) Ein NaN erzeugen
nearbyint Rundet Gleitkommazahlen zum nächsten Integer
nextafter(x,y) Gibt die nächst darstellbare Zahl nach x (Richtung y) zurück
nexttoward(x,y) Genauso wie nextafter, bis auf y wird immer als long double zurückgegeben
remainder(x,y) Rest einer Division
remquo(x,y,p) Genauso wie remainder, speichert jedoch den Quotienten (als int) als Ziel des Zeigers p
rint Rundet zum Integer
round Rundungsfunktion
scalbln(x,n) x * FLT_RADIXn (n ist long)
scalbn(x,n) x * FLT_RADIXn (n ist int)
tgamma Gammafunktion
trunc Trunktiert eine Gleitkommazahl

Beispiel

#include <stdlib.h>
#include <math.h>
 
int main()
{
     float a = 5, b = 4, c;
 
     c = pow(a, b);
 
     return EXIT_SUCCESS;
}

Weblinks


Wikimedia Foundation.

Игры ⚽ Нужна курсовая?

Schlagen Sie auch in anderen Wörterbüchern nach:

  • math — math …   Dictionnaire des rimes

  • Math 55 — is a two semester long first year undergraduate mathematics course at Harvard University. The official titles of the course is Honors Abstract Algebra and Honors Real and Complex Analysis. (The official title was previously Honors Advanced… …   Wikipedia

  • Math — Math, vollständiger Name Math fab Mathonwy [maːθ vaːb ma θonwi] oder Math ap Mathonwy („Math, Sohn des Mathonwy“), ist in der keltischen Mythologie von Wales König von Gwynedd. Seine Neffen sind Gwydyon und Gilfaethwy, seine Nichte ist… …   Deutsch Wikipedia

  • Math — (homonymie) Cette page d’homonymie répertorie les différents sujets et articles partageant un même nom. Math est un diminutif possible de Mathieu  , voir aussi Matt. en informatique : Math est un logiciel de la …   Wikipédia en Français

  • math — S2 [mæθ] n [U] [Date: 1800 1900; Origin: mathematics] AmE mathematics British Equivalent: maths ▪ Tim s good at math and science. ▪ a set of simple math problems (=questions that are related to math) ▪ She s learning calculus in math class. ▪ a… …   Dictionary of contemporary English

  • Math.h — Saltar a navegación, búsqueda math.h es un archivo de cabecera de la biblioteca estándar del lenguaje de programación C diseñado para operaciones matemáticas básicas. Muchas de sus funciones incluyen el uso de números en coma flotante. C++… …   Wikipedia Español

  • Math.h — Стандартная библиотека языка программирования С assert.h complex.h ctype.h errno.h fenv.h float.h inttypes.h iso646.h limits.h locale.h math.h setjmp.h signal.h stdarg.h stdbool.h stddef.h stdint.h stdio.h stdlib.h …   Википедия

  • Math — (m[a^]th), n. [AS. m[=ae][eth]; akin to m[=a]wan to mow, G. mahd math. See {Mow} to cut (grass).] A mowing, or that which is gathered by mowing; chiefly used in composition; as, an aftermath. [Obs.] [1913 Webster] The first mowing thereof, for… …   The Collaborative International Dictionary of English

  • Math.h — is a header file in the standard library of C programming language designed for basic mathematical operations. Most of the functions involve the use of floating point numbers. C++ also implements these functions for compatibility reasons and… …   Wikipedia

  • math.h — es un archivo de cabecera de la biblioteca estándar del lenguaje de programación C diseñado para operaciones matemáticas básicas. Muchas de sus funciones incluyen el uso de números en coma flotante. C++ también implementa estas funciones por… …   Wikipedia Español

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”