Update copyright notices with scripts/update-copyrights.
[glibc.git] / sysdeps / powerpc / fpu / s_llroundf.c
blob07d12adbfbf4e999184cfcdd30c06fd303a016d8
1 /* Round float value to long long int.
2 Copyright (C) 1997-2013 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <math.h>
21 /* I think that what this routine is supposed to do is round a value
22 to the nearest integer, with values exactly on the boundary rounded
23 away from zero. */
24 /* This routine relies on (long long)x, when x is out of range of a long long,
25 clipping to MAX_LLONG or MIN_LLONG. */
27 long long int
28 __llroundf (float x)
30 float xrf;
31 long long int xr;
32 xr = (long long int) x;
33 xrf = (float) xr;
34 if (x >= 0.0)
35 if (x - xrf >= 0.5 && x - xrf < 1.0 && x+1 > 0)
36 return x+1;
37 else
38 return x;
39 else
40 if (xrf - x >= 0.5 && xrf - x < 1.0 && x-1 < 0)
41 return x-1;
42 else
43 return x;
45 weak_alias (__llroundf, llroundf)