1 |
|
/* |
2 |
|
** Copyright (C) 2018 Martin Brain |
3 |
|
** |
4 |
|
** See the file LICENSE for licensing information. |
5 |
|
*/ |
6 |
|
|
7 |
|
/* |
8 |
|
** sign.h |
9 |
|
** |
10 |
|
** Martin Brain |
11 |
|
** martin.brain@cs.ox.ac.uk |
12 |
|
** 21/08/14 |
13 |
|
** |
14 |
|
** The sign manipulating operations. |
15 |
|
** |
16 |
|
*/ |
17 |
|
|
18 |
|
#include "symfpu/core/unpackedFloat.h" |
19 |
|
|
20 |
|
#ifndef SYMFPU_SIGN |
21 |
|
#define SYMFPU_SIGN |
22 |
|
|
23 |
|
namespace symfpu { |
24 |
|
|
25 |
|
template <class t> |
26 |
725 |
unpackedFloat<t> negate (const typename t::fpt &format, const unpackedFloat<t> &uf) { |
27 |
|
|
28 |
725 |
PRECONDITION(uf.valid(format)); |
29 |
|
|
30 |
725 |
unpackedFloat<t> result(uf, !uf.getSign()); |
31 |
|
|
32 |
725 |
POSTCONDITION(result.valid(format)); |
33 |
|
|
34 |
725 |
return result; |
35 |
|
} |
36 |
|
|
37 |
|
template <class t> |
38 |
18 |
unpackedFloat<t> absolute (const typename t::fpt &format, const unpackedFloat<t> &uf) { |
39 |
|
|
40 |
18 |
PRECONDITION(uf.valid(format)); |
41 |
|
|
42 |
18 |
unpackedFloat<t> result(uf, typename t::prop(false)); |
43 |
|
|
44 |
18 |
POSTCONDITION(result.valid(format)); |
45 |
|
|
46 |
18 |
return result; |
47 |
|
} |
48 |
|
|
49 |
|
|
50 |
|
} |
51 |
|
|
52 |
|
#endif |