1
/* tsgn -- Test for the sign of a floating point number.
3
Copyright 2003 Free Software Foundation.
4
Contributed by the Spaces project, INRIA Lorraine.
6
This file is part of the MPFR Library.
8
The MPFR Library is free software; you can redistribute it and/or modify
9
it under the terms of the GNU Lesser General Public License as published by
10
the Free Software Foundation; either version 2.1 of the License, or (at your
11
option) any later version.
13
The MPFR Library is distributed in the hope that it will be useful, but
14
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16
License for more details.
18
You should have received a copy of the GNU Lesser General Public License
19
along with the MPFR Library; see the file COPYING.LIB. If not, write to
20
the Free Software Foundation, Inc., 51 Franklin Place, Fifth Floor, Boston,
21
MA 02110-1301, USA. */
26
#include "mpfr-test.h"
36
if ((mpfr_sgn) (x) != 0)
38
printf("Sgn error for 0.\n");
43
if ((mpfr_sgn) (x) != 1)
45
printf("Sgn error for +Inf.\n");
50
if ((mpfr_sgn) (x) != -1)
52
printf("Sgn error for -Inf.\n");
67
for(i = 0 ; i < 100 ; i++)
81
if (s1 < -1 || s1 > 1)
83
printf("Error for sgn: out of range.\n");
86
else if (MPFR_IS_NAN(x) || MPFR_IS_ZERO(x))
90
printf("Error for sgn: Nan or Zero should return 0.\n");
96
printf("Error for sgn. Return %d instead of %d.\n", s1, s2);
109
main (int argc, char *argv[])