PrevUpHomeNext

cpp std float type


c++ std float type - Posted on Jun 12, 2024 - See https://kubuntu.org - Logs Home - d0022

cpp std float type

std::float16_t, std::bfloat16_t, std::float32_t, std::float64_t, std::float128_t

cpp/c++ code:

#include <stdfloat>
#include <iostream>
#include <boost/assert.hpp>

int main()
{
	static_assert(std::floating_point<std::float16_t>);
	static_assert(std::floating_point<std::bfloat16_t>);
	static_assert(std::floating_point<std::float32_t>);
	static_assert(std::floating_point<std::float64_t>);
	static_assert(std::floating_point<std::float128_t>);
	constexpr std::float16_t a{};
	constexpr std::bfloat16_t b{};
	constexpr std::float32_t c{};
	constexpr std::float64_t d{};
	constexpr std::float128_t e{};
	static_assert(sizeof a == 2);
	static_assert(sizeof b == 2);
	static_assert(sizeof c == 4);
	static_assert(sizeof d == 8);
	static_assert(sizeof e == 16);
	BOOST_ASSERT(true);
	std::cout << "Hello c++!" << std::endl;
}

See Also

cppfx

cpp/c++

c++ std::exception:

std::cout.write(err.data(), err.size());

std::cout << std::endl;

caught:

  ===================================
  #  The c++ programming language.  #
  #                                 #
  #  Join c++ Discord: yZcauUAUyC   #
  #  Deck                           #
  ===================================

Home: cppfx.xyz

K


PrevUpHomeNext