Lines Matching refs:ndigits
953 10**-ndigits; here ndigits is within reasonable bounds (typically, -308 <=
954 ndigits <= 323). Returns a Python float, or sets a Python error and
962 double_round(double x, int ndigits) {
973 buf = _Py_dg_dtoa(x, 3, ndigits, &decpt, &sign, &buf_end);
1020 double_round(double x, int ndigits) {
1022 if (ndigits >= 0) {
1023 if (ndigits > 22) {
1025 pow1*pow2 ~= pow(10.0, ndigits) might overflow */
1026 pow1 = pow(10.0, (double)(ndigits-22));
1030 pow1 = pow(10.0, (double)ndigits);
1039 pow1 = pow(10.0, (double)-ndigits);
1049 if (ndigits >= 0)
1066 /* round a Python float v to the closest multiple of 10**-ndigits */
1071 ndigits as o_ndigits: object = None
1076 When an argument is passed, work like built-in round(x, ndigits).
1084 Py_ssize_t ndigits;
1088 /* single-argument round or with None ndigits:
1098 ndigits = PyNumber_AsSsize_t(o_ndigits, NULL);
1099 if (ndigits == -1 && PyErr_Occurred())
1106 /* Deal with extreme values for ndigits. For ndigits > NDIGITS_MAX, x
1107 always rounds to itself. For ndigits < NDIGITS_MIN, x always
1111 if (ndigits > NDIGITS_MAX)
1114 else if (ndigits < NDIGITS_MIN)
1118 /* finite x, and ndigits is not unreasonably large */
1119 return double_round(x, (int)ndigits);
1318 Py_ssize_t length, ndigits, fdigits, i;
1322 * limit on ndigits, the total number of hex digits in the coefficient
1334 * More specifically, ndigits is assumed to satisfy the following
1337 * 4*ndigits <= DBL_MIN_EXP - DBL_MANT_DIG - LONG_MIN/2
1338 * 4*ndigits <= LONG_MAX/2 + 1 - DBL_MAX_EXP
1344 * 2**(exp-4*ndigits) <= |x| < 2**(exp+4*ndigits).
1348 * exp - 4*ndigits >= LONG_MAX/2 + 1 - (LONG_MAX/2 + 1 - DBL_MAX_EXP)
1354 * exp + 4*ndigits <= LONG_MIN/2 - 1 + (
1362 * exp+4*ndigits and exp-4*ndigits are within the range of a long.
1417 /* ndigits = total # of hex digits; fdigits = # after point */
1418 ndigits = coeff_end - coeff_start;
1420 if (ndigits == 0)
1422 if (ndigits > Py_MIN(DBL_MIN_EXP - DBL_MANT_DIG - LONG_MIN/2,
1442 /* for 0 <= j < ndigits, HEX_DIGIT(j) gives the jth most significant digit */
1452 while (ndigits > 0 && HEX_DIGIT(ndigits-1) == 0)
1453 ndigits--;
1454 if (ndigits == 0 || exp < LONG_MIN/2) {
1465 top_exp = exp + 4*((long)ndigits - 1);
1466 for (digit = HEX_DIGIT(ndigits-1); digit != 0; digit /= 2)
1484 for (i = ndigits-1; i >= 0; i--)
1493 for (i = ndigits-1; i > key_digit; i--)
1503 key_digit+1 < ndigits && (HEX_DIGIT(key_digit+1) & 1) != 0))