# std::floating_point

> C++ Atlas: `cppatlas.com/w/cpp/concepts/floating_point` | Source: https://en.cppreference.com/w/cpp/concepts/floating_point | Domain: Concepts | Standards: C++11, C++20

The concept floating_point<T> is satisfied if and only if T is a floating-point type.

## Official Specification Summary (cppreference)

```cpp
// Defined in header <concepts>

template< class T >
concept floating_point = std::is_floating_point_v<T>; // (since C++20)
```

The concept `floating_point<T>` is satisfied if and only if `T` is a floating-point type.

### Example

```cpp
#include <concepts>
#include <iostream>
#include <type_traits>

constexpr std::floating_point auto x2(std::floating_point auto x)
{
    return x + x;
}

constexpr std::integral auto x2(std::integral auto x)
{
    return x << 1;
}

int main()
{
    constexpr auto d = x2(1.1);
    static_assert(std::is_same_v<double const, decltype(d)>);
    std::cout << d << '\n';

    constexpr auto f = x2(2.2f);
    static_assert(std::is_same_v<float const, decltype(f)>);
    std::cout << f << '\n';

    constexpr auto i = x2(444);
    static_assert(std::is_same_v<int const, decltype(i)>);
    std::cout << i << '\n';
}
```

Output:

```text
2.2
4.4
888
```

### References

- C++23 standard (ISO/IEC 14882:2024):

  - 18.4.7 Arithmetic concepts [concepts.arithmetic]

- C++20 standard (ISO/IEC 14882:2020):

  - 18.4.7 Arithmetic concepts [concepts.arithmetic]

### See also

- [`is_floating_point`](https://en.cppreference.com/w/cpp/types/is_floating_point) (C++11): checks if a type is a floating-point type (class template)

---
Attribution: content from https://en.cppreference.com/w/cpp/concepts/floating_point (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.