LCOV - code coverage report
Current view: top level - src - ieee_float.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 8 8 100.0 %
Date: 2026-07-14 21:28:07 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // Copyright 2019-2021 David Robillard <d@drobilla.net>
       2                 :            : // SPDX-License-Identifier: ISC
       3                 :            : 
       4                 :            : #ifndef EXESS_SRC_IEEE_FLOAT_H
       5                 :            : #define EXESS_SRC_IEEE_FLOAT_H
       6                 :            : 
       7                 :            : #include <float.h>
       8                 :            : #include <stdint.h>
       9                 :            : #include <string.h>
      10                 :            : 
      11                 :            : static const unsigned dbl_physical_mant_dig = DBL_MANT_DIG - 1U;
      12                 :            : static const uint64_t dbl_mant_mask         = 0x000FFFFFFFFFFFFFULL;
      13                 :            : static const uint64_t dbl_expt_mask         = 0x7FF0000000000000UL;
      14                 :            : static const uint64_t dbl_hidden_bit        = 0x0010000000000000UL;
      15                 :            : static const int      dbl_expt_bias         = 0x3FF + DBL_MANT_DIG - 1;
      16                 :            : static const int      dbl_subnormal_expt    = -0x3FF - DBL_MANT_DIG + 2;
      17                 :            : 
      18                 :            : /// Return the raw representation of a float
      19                 :            : static inline uint32_t
      20                 :      25712 : float_to_rep(const float d)
      21                 :            : {
      22                 :      25712 :   uint32_t rep = 0;
      23                 :      25712 :   memcpy(&rep, &d, sizeof(rep));
      24                 :      25712 :   return rep;
      25                 :            : }
      26                 :            : 
      27                 :            : /// Return the raw representation of a double
      28                 :            : static inline uint64_t
      29                 :     109834 : double_to_rep(const double d)
      30                 :            : {
      31                 :     109834 :   uint64_t rep = 0;
      32                 :     109834 :   memcpy(&rep, &d, sizeof(rep));
      33                 :     109834 :   return rep;
      34                 :            : }
      35                 :            : 
      36                 :            : #endif // EXESS_SRC_IEEE_FLOAT_H

Generated by: LCOV version 1.16