GCC Code Coverage Report
Directory: . Exec Total Coverage
File: deps/install/include/symfpu/core/classify.h Lines: 21 21 100.0 %
Date: 2021-03-23 Branches: 38 64 59.4 %

Line Exec Source
1
/*
2
** Copyright (C) 2018 Martin Brain
3
**
4
** See the file LICENSE for licensing information.
5
*/
6
7
/*
8
** classify.h
9
**
10
** Martin Brain
11
** martin.brain@cs.ox.ac.uk
12
** 21/08/14
13
**
14
** The classification functions for different classes of float.
15
**
16
*/
17
18
#include "symfpu/core/unpackedFloat.h"
19
20
#ifndef SYMFPU_CLASSIFY
21
#define SYMFPU_CLASSIFY
22
23
namespace symfpu {
24
25
template <class t>
26
43
  typename t::prop isNormal (const typename t::fpt &format, const unpackedFloat<t> &uf) {
27
43
  PRECONDITION(uf.valid(format));
28
29
43
  return !uf.getNaN() && !uf.getInf() && !uf.getZero() && uf.inNormalRange(format, typename t::prop(true));
30
 }
31
32
33
template <class t>
34
44
  typename t::prop isSubnormal (const typename t::fpt &format, const unpackedFloat<t> &uf) {
35
44
  PRECONDITION(uf.valid(format));
36
37
44
  return !uf.getNaN() && !uf.getInf() && !uf.getZero() && uf.inSubnormalRange(format, typename t::prop(true));
38
 }
39
40
41
template <class t>
42
270
  typename t::prop isZero (const typename t::fpt &format, const unpackedFloat<t> &uf) {
43
270
  PRECONDITION(uf.valid(format));
44
45
270
  return uf.getZero();
46
 }
47
48
49
template <class t>
50
69
  typename t::prop isInfinite (const typename t::fpt &format, const unpackedFloat<t> &uf) {
51
69
  PRECONDITION(uf.valid(format));
52
53
69
  return uf.getInf();
54
 }
55
56
57
template <class t>
58
56
  typename t::prop isNaN (const typename t::fpt &format, const unpackedFloat<t> &uf) {
59
56
  PRECONDITION(uf.valid(format));
60
61
56
  return uf.getNaN();
62
 }
63
64
65
// Note these are the SMT-LIB semantics, NaN is neither positive or negative
66
67
template <class t>
68
13
  typename t::prop isPositive (const typename t::fpt &format, const unpackedFloat<t> &uf) {
69
13
  PRECONDITION(uf.valid(format));
70
71
13
  return !uf.getNaN() && !uf.getSign();
72
 }
73
74
template <class t>
75
47
  typename t::prop isNegative (const typename t::fpt &format, const unpackedFloat<t> &uf) {
76
47
  PRECONDITION(uf.valid(format));
77
78
47
  return !uf.getNaN() && uf.getSign();
79
 }
80
81
82
// C semantics
83
84
 template <class t>
85
  typename t::prop isFinite (const typename t::fpt &format, const unpackedFloat<t> &uf) {
86
  PRECONDITION(uf.valid(format));
87
88
  return !uf.getNaN() && !uf.getInf();
89
 }
90
91
92
}
93
94
#endif
95