s_roundl.c (144772) | s_roundl.c (153017) |
---|---|
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_roundl.c 144772 2005-04-08 01:24:08Z das $"); | 28__FBSDID("$FreeBSD: head/lib/msun/src/s_roundl.c 153017 2005-12-02 13:45:06Z bde $"); |
29 30#include <math.h> 31 32long double 33roundl(long double x) 34{ 35 long double t; 36 37 if (!isfinite(x)) 38 return (x); 39 40 if (x >= 0.0) { | 29 30#include <math.h> 31 32long double 33roundl(long double x) 34{ 35 long double t; 36 37 if (!isfinite(x)) 38 return (x); 39 40 if (x >= 0.0) { |
41 t = ceill(x); 42 if (t - x > 0.5) 43 t -= 1.0; | 41 t = floorl(x); 42 if (t - x <= -0.5) 43 t += 1.0; |
44 return (t); 45 } else { | 44 return (t); 45 } else { |
46 t = ceill(-x); 47 if (t + x > 0.5) 48 t -= 1.0; | 46 t = floorl(-x); 47 if (t + x <= -0.5) 48 t += 1.0; |
49 return (-t); 50 } 51} | 49 return (-t); 50 } 51} |