PIPS
abs.c
Go to the documentation of this file.
1
/*
2
3
$Id: abs.c 1669 2019-06-26 17:24:57Z coelho $
4
5
Copyright 1989-2016 MINES ParisTech
6
7
This file is part of Linear/C3 Library.
8
9
Linear/C3 Library is free software: you can redistribute it and/or modify it
10
under the terms of the GNU Lesser General Public License as published by
11
the Free Software Foundation, either version 3 of the License, or
12
any later version.
13
14
Linear/C3 Library is distributed in the hope that it will be useful, but WITHOUT ANY
15
WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
FITNESS FOR A PARTICULAR PURPOSE.
17
18
See the GNU Lesser General Public License for more details.
19
20
You should have received a copy of the GNU Lesser General Public License
21
along with Linear/C3 Library. If not, see <http://www.gnu.org/licenses/>.
22
23
*/
24
25
#ifdef HAVE_CONFIG_H
26
#include "config.h"
27
#endif
28
#include <stdlib.h>
29
#include <stdio.h>
30
#include <limits.h>
31
32
#include "
arithmetique.h
"
33
#include "
linear_assert.h
"
34
35
/* it seems rather stupid to trap arithmetic errors on abs... FC.
36
*/
37
38
Value
abs_ofl_ctrl
(
Value
i,
int
ofl_ctrl)
39
{
40
41
if
((ofl_ctrl == 1) &&
value_eq
(i,
VALUE_MIN
))
42
THROW
(
overflow_error
);
43
44
assert
(
value_ne
(i,
VALUE_MIN
));
45
return
value_pos_p
(i)? i:
value_uminus
(i);
46
}
47
48
/* int absval_ofl(int i): absolute value of i (SUN version)
49
*/
50
Value
absval_ofl
(
Value
i)
51
{
52
return
abs_ofl_ctrl
(i, 1);
53
}
54
55
56
/* int absval(int i): absolute value of i (SUN version)
57
*/
58
Value
absval
(
Value
i)
59
{
60
return
abs_ofl_ctrl
(i, 0);
61
}
abs_ofl_ctrl
Value abs_ofl_ctrl(Value i, int ofl_ctrl)
it seems rather stupid to trap arithmetic errors on abs...
Definition:
abs.c:38
absval_ofl
Value absval_ofl(Value i)
int absval_ofl(int i): absolute value of i (SUN version)
Definition:
abs.c:50
absval
Value absval(Value i)
int absval(int i): absolute value of i (SUN version)
Definition:
abs.c:58
overflow_error
@ overflow_error
Definition:
arithmetic_errors.h:48
THROW
#define THROW(what)
Definition:
arithmetic_errors.h:69
value_pos_p
#define value_pos_p(val)
Definition:
arithmetique-local.h:384
value_uminus
#define value_uminus(val)
unary operators on values
Definition:
arithmetique-local.h:377
VALUE_MIN
#define VALUE_MIN
Definition:
arithmetique-local.h:300
value_ne
#define value_ne(v1, v2)
Definition:
arithmetique-local.h:325
Value
int Value
Definition:
arithmetique-local.h:296
value_eq
#define value_eq(v1, v2)
bool operators on values
Definition:
arithmetique-local.h:324
arithmetique.h
linear_assert.h
assert
#define assert(ex)
Definition:
newgen_assert.h:41
linear
src
arithmetique
abs.c
Generated on Thu Sep 26 2024 22:11:28 for PIPS by
1.9.1