Deleted Added
full compact
s_round.c (133146) s_round.c (140188)
1/*-
2 * Copyright (c) 2003, Steven G. Kargl
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2003, Steven G. Kargl
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/lib/msun/src/s_round.c 133146 2004-08-05 01:44:55Z das $");
28__FBSDID("$FreeBSD: head/lib/msun/src/s_round.c 140188 2005-01-13 15:43:41Z das $");
29
30#include <math.h>
31
32double
33round(double x)
34{
35 double t;
36
29
30#include <math.h>
31
32double
33round(double x)
34{
35 double t;
36
37 if (!isnormal(x))
37 if (!isfinite(x))
38 return (x);
39
40 if (x >= 0.0) {
41 t = ceil(x);
42 if (t - x > 0.5)
43 t -= 1.0;
44 return (t);
45 } else {
46 t = ceil(-x);
47 if (t + x > 0.5)
48 t -= 1.0;
49 return (-t);
50 }
51}
38 return (x);
39
40 if (x >= 0.0) {
41 t = ceil(x);
42 if (t - x > 0.5)
43 t -= 1.0;
44 return (t);
45 } else {
46 t = ceil(-x);
47 if (t + x > 0.5)
48 t -= 1.0;
49 return (-t);
50 }
51}