The R Project SVN R

Rev

Rev 77727 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 77727 Rev 81787
Line 30... Line 30...
30
 
30
 
31
#include <config.h> /* needed for HAVE_* */
31
#include <config.h> /* needed for HAVE_* */
32
#include "nmath.h"
32
#include "nmath.h"
33
 
33
 
34
double fround(double x, double digits) {
34
double fround(double x, double digits) {
35
#define MAX_DIGITS (DBL_MAX_10_EXP + DBL_DIG)
35
#define MAX_DIGITS (DBL_MAX_10_EXP + DBL_DIG) /* typically = 308+15 = 323
36
    /* was DBL_MAX_10_EXP (= 308, IEEE) till R 3.6.x; before,
36
    * was DBL_MAX_10_EXP (= 308, IEEE) till R 3.6.x; before,
37
       was (DBL_DIG - 1)  till R 0.99  */
37
    * was (DBL_DIG - 1)  till R 0.99  */
38
    const static int max10e = (int) DBL_MAX_10_EXP; // == 308 ("IEEE")
38
    const static int max10e = (int) DBL_MAX_10_EXP; // == 308 ("IEEE")
39
 
39
 
40
    /* Note that large digits make sense for very small numbers */
40
    /* Note that large digits make sense for very small numbers */
41
    if (ISNAN(x) || ISNAN(digits))
41
    if (ISNAN(x) || ISNAN(digits))
42
	return x + digits;
42
	return x + digits;