LCOV - code coverage report
Current view: top level - src - float.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 10 10 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-2026 David Robillard <d@drobilla.net>
       2                 :            : // SPDX-License-Identifier: ISC
       3                 :            : 
       4                 :            : #include "big_decimal.h"
       5                 :            : #include "double_to_decimal.h"
       6                 :            : #include "scientific.h"
       7                 :            : #include "write_utils.h"
       8                 :            : 
       9                 :            : #include <exess/exess.h>
      10                 :            : 
      11                 :            : #include <math.h>
      12                 :            : #include <string.h>
      13                 :            : 
      14                 :            : #ifndef FLT_DECIMAL_DIG
      15                 :            : #  define FLT_DECIMAL_DIG 9U
      16                 :            : #endif
      17                 :            : 
      18                 :            : EXESS_NONBLOCKING ExessResult
      19                 :      13019 : exess_read_float(const char* const str, float* const out)
      20                 :            : {
      21                 :      13019 :   double            value = (double)NAN;
      22                 :      13019 :   const ExessResult r     = exess_read_double(str, &value);
      23                 :            : 
      24                 :      13019 :   *out = (float)value;
      25                 :            : 
      26                 :      13019 :   return r;
      27                 :            : }
      28                 :            : 
      29                 :            : EXESS_NONBLOCKING ExessResult
      30                 :      13037 : exess_write_float(const float value, const size_t buf_size, char* const buf)
      31                 :            : {
      32                 :      13037 :   char digits[FLT_DECIMAL_DIG + 1U] = {0};
      33                 :            : 
      34                 :            :   const BigDecimal decimal =
      35                 :      13037 :     double_to_decimal((double)value, FLT_DECIMAL_DIG, digits);
      36                 :            : 
      37                 :      13037 :   const ExessResult r = write_scientific(decimal, digits, buf_size, buf);
      38                 :      13037 :   return end_write(r.status, buf_size, buf, r.count);
      39                 :            : }

Generated by: LCOV version 1.16