diff options
Diffstat (limited to 'gl/floor.c')
| -rw-r--r-- | gl/floor.c | 34 | 
1 files changed, 17 insertions, 17 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Round towards negative infinity. | 1 | /* Round towards negative infinity. | 
| 2 | Copyright (C) 2007 Free Software Foundation, Inc. | 2 | Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. | 
| 3 | 3 | ||
| 4 | This program is free software: you can redistribute it and/or modify | 4 | This program is free software: you can redistribute it and/or modify | 
| 5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by | 
| @@ -67,27 +67,27 @@ FUNC (DOUBLE x) | |||
| 67 | { | 67 | { | 
| 68 | /* Avoid rounding errors for values near 2^k, where k >= MANT_DIG-1. */ | 68 | /* Avoid rounding errors for values near 2^k, where k >= MANT_DIG-1. */ | 
| 69 | if (z < TWO_MANT_DIG) | 69 | if (z < TWO_MANT_DIG) | 
| 70 | { | 70 | { | 
| 71 | /* Round to the next integer (nearest or up or down, doesn't matter). */ | 71 | /* Round to the next integer (nearest or up or down, doesn't matter). */ | 
| 72 | z += TWO_MANT_DIG; | 72 | z += TWO_MANT_DIG; | 
| 73 | z -= TWO_MANT_DIG; | 73 | z -= TWO_MANT_DIG; | 
| 74 | /* Enforce rounding down. */ | 74 | /* Enforce rounding down. */ | 
| 75 | if (z > y) | 75 | if (z > y) | 
| 76 | z -= L_(1.0); | 76 | z -= L_(1.0); | 
| 77 | } | 77 | } | 
| 78 | } | 78 | } | 
| 79 | else if (z < L_(0.0)) | 79 | else if (z < L_(0.0)) | 
| 80 | { | 80 | { | 
| 81 | /* Avoid rounding errors for values near -2^k, where k >= MANT_DIG-1. */ | 81 | /* Avoid rounding errors for values near -2^k, where k >= MANT_DIG-1. */ | 
| 82 | if (z > - TWO_MANT_DIG) | 82 | if (z > - TWO_MANT_DIG) | 
| 83 | { | 83 | { | 
| 84 | /* Round to the next integer (nearest or up or down, doesn't matter). */ | 84 | /* Round to the next integer (nearest or up or down, doesn't matter). */ | 
| 85 | z -= TWO_MANT_DIG; | 85 | z -= TWO_MANT_DIG; | 
| 86 | z += TWO_MANT_DIG; | 86 | z += TWO_MANT_DIG; | 
| 87 | /* Enforce rounding down. */ | 87 | /* Enforce rounding down. */ | 
| 88 | if (z > y) | 88 | if (z > y) | 
| 89 | z -= L_(1.0); | 89 | z -= L_(1.0); | 
| 90 | } | 90 | } | 
| 91 | } | 91 | } | 
| 92 | return z; | 92 | return z; | 
| 93 | } | 93 | } | 
