Namespaces
Variants

float_t, double_t

From cppreference.net
< c ‎ | numeric ‎ | math
Common mathematical functions
Functions
Basic operations
(C99)
(C99)
(C99)
(C99) (C99) (C99) (C23)
Maximum/minimum operations
Exponential functions
Power functions
Trigonometric and hyperbolic functions
Nearest integer floating-point
(C99) (C99) (C99)
(C23) (C23) (C23) (C23)
Floating-point manipulation
Narrowing operations
(C23)
(C23)
(C23)
(C23)
(C23)
(C23)
Quantum and quantum exponent
Decimal re-encoding functions
Total order and payload functions
Classification
Error and gamma functions
(C99)
(C99)
(C99)
(C99)
Types
float_t double_t
(C99) (C99)
Macro constants
Special floating-point values
Arguments and return values
Error handling
Fast operation indicators
Definiert im Header <math.h>
typedef /* implementation-defined */ float_t
(seit C99)
typedef /* implementation-defined */ double_t
(seit C99)

Die Typen float_t und double_t sind Gleitkommatypen, die mindestens so breit sind wie float bzw. double , und zwar so, dass double_t mindestens so breit ist wie float_t . Der Wert von FLT_EVAL_METHOD bestimmt die Typen von float_t und double_t .

FLT_EVAL_METHOD Erklärung
0 float_t und double_t entsprechen float bzw. double
1 sowohl float_t als auch double_t entsprechen double
2 sowohl float_t als auch double_t entsprechen long double
other sowohl float_t als auch double_t sind implementierungsdefiniert

Beispiel

#include <float.h>
#include <math.h>
#include <stdio.h>
#define SHOW(expr) printf("%s = %d\n", #expr, (int)(expr))
int main()
{
    SHOW(FLT_EVAL_METHOD);
    SHOW(sizeof(float));
    SHOW(sizeof(float_t));
    SHOW(sizeof(double));
    SHOW(sizeof(double_t));
}

Mögliche Ausgabe:

FLT_EVAL_METHOD = 1
sizeof(float) = 4
sizeof(float_t) = 8
sizeof(double) = 8
sizeof(double_t) = 8

Referenzen

  • C23-Standard (ISO/IEC 9899:2024):
  • 7.12 Mathematik <math.h> (S: TBD)
  • C17-Standard (ISO/IEC 9899:2018):
  • 7.12 Mathematik <math.h> (S: TBD)
  • C11-Standard (ISO/IEC 9899:2011):
  • 7.12 Mathematik <math.h> (S: 231)
  • C99-Standard (ISO/IEC 9899:1999):
  • 7.12 Mathematik <math.h> (S: 212)

Siehe auch

gibt an, in welcher Genauigkeit alle arithmetischen Operationen durchgeführt werden
(Makrokonstante)