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))
43 
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  */
51 {
52  return abs_ofl_ctrl(i, 1);
53 }
54 
55 
56 /* int absval(int i): absolute value of i (SUN version)
57  */
59 {
60  return abs_ofl_ctrl(i, 0);
61 }
Value abs_ofl_ctrl(Value i, int ofl_ctrl)
it seems rather stupid to trap arithmetic errors on abs...
Definition: abs.c:38
Value absval_ofl(Value i)
int absval_ofl(int i): absolute value of i (SUN version)
Definition: abs.c:50
Value absval(Value i)
int absval(int i): absolute value of i (SUN version)
Definition: abs.c:58
@ overflow_error
#define THROW(what)
#define value_pos_p(val)
#define value_uminus(val)
unary operators on values
#define VALUE_MIN
#define value_ne(v1, v2)
int Value
#define value_eq(v1, v2)
bool operators on values
#define assert(ex)
Definition: newgen_assert.h:41