Coverage Report

Created: 2026-06-30 06:38

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/duckdb/extension/parquet/parquet_float16.cpp
Line
Count
Source
1
#include "parquet_float16.hpp"
2
3
#include "duckdb/common/helper.hpp"
4
#include "duckdb/common/typedefs.hpp"
5
6
namespace duckdb {
7
8
0
float Float16ToFloat32(const uint16_t &float16_value) {
9
0
  uint32_t sign = float16_value >> 15;
10
0
  uint32_t exponent = (float16_value >> 10) & 0x1F;
11
0
  uint32_t fraction = (float16_value & 0x3FF);
12
  // Avoid strict aliasing issues and compiler warnings
13
0
  uint32_t float32_value = 0;
14
15
0
  if (exponent == 0) {
16
0
    if (fraction == 0) {
17
      // zero
18
0
      float32_value = (sign << 31);
19
0
    } else {
20
      // can be represented as ordinary value in float32
21
      // 2 ** -14 * 0.0101
22
      // => 2 ** -16 * 1.0100
23
      // int int_exponent = -14;
24
0
      exponent = 127 - 14;
25
0
      while ((fraction & (1 << 10)) == 0) {
26
        // int_exponent--;
27
0
        exponent--;
28
0
        fraction <<= 1;
29
0
      }
30
0
      fraction &= 0x3FF;
31
      // int_exponent += 127;
32
0
      float32_value = (sign << 31) | (exponent << 23) | (fraction << 13);
33
0
    }
34
0
  } else if (exponent == 0x1F) {
35
    /* Inf or NaN */
36
0
    float32_value = (sign << 31) | (0xFF << 23) | (fraction << 13);
37
0
  } else {
38
    /* ordinary number */
39
0
    float32_value = (sign << 31) | ((exponent + (127 - 15)) << 23) | (fraction << 13);
40
0
  }
41
42
0
  return Load<float>(const_data_ptr_cast(&float32_value));
43
0
}
44
45
} // namespace duckdb