5 #ifndef V8_BOXED_FLOAT_H_ 6 #define V8_BOXED_FLOAT_H_ 9 #include "src/base/macros.h" 10 #include "src/globals.h" 25 explicit Float32(
float value) : bit_pattern_(bit_cast<uint32_t>(value)) {
28 DCHECK(!std::isnan(value));
31 uint32_t get_bits()
const {
return bit_pattern_; }
33 float get_scalar()
const {
return bit_cast<
float>(bit_pattern_); }
38 return std::isnan(get_scalar());
43 uint32_t* get_bits_address() {
return &bit_pattern_; }
51 : bit_pattern_(bit_pattern) {}
54 ASSERT_TRIVIALLY_COPYABLE(
Float32);
65 explicit Float64(
double value) : bit_pattern_(bit_cast<uint64_t>(value)) {
68 DCHECK(!std::isnan(value));
71 uint64_t get_bits()
const {
return bit_pattern_; }
72 double get_scalar()
const {
return bit_cast<
double>(bit_pattern_); }
73 bool is_hole_nan()
const {
return bit_pattern_ == kHoleNanInt64; }
77 return std::isnan(get_scalar());
82 uint64_t* get_bits_address() {
return &bit_pattern_; }
84 static constexpr
Float64 FromBits(uint64_t bits) {
return Float64(bits); }
87 uint64_t bit_pattern_ = 0;
89 explicit constexpr
Float64(uint64_t bit_pattern)
90 : bit_pattern_(bit_pattern) {}
93 ASSERT_TRIVIALLY_COPYABLE(
Float64);
98 #endif // V8_BOXED_FLOAT_H_