Home | History | Annotate | Download | only in python2.7

Lines Matching refs:rounding

149 # Rounding
286 """Invalid context. Unknown rounding, for example.
291 underlying concrete representation or an unknown or unsupported rounding
300 """Number got rounded (not necessarily changed during rounding).
312 """Exponent < Emin before rounding.
316 Emin, before any rounding). The result in all cases is unchanged.
327 by zero), after rounding, would be greater than the largest value that
330 The result depends on the rounding mode:
345 if context.rounding in (ROUND_HALF_UP, ROUND_HALF_EVEN,
349 if context.rounding == ROUND_CEILING:
354 if context.rounding == ROUND_FLOOR:
1074 if not self and context.rounding != ROUND_FLOOR:
1076 # in ROUND_FLOOR rounding mode.
1096 if not self and context.rounding != ROUND_FLOOR:
1097 # + (-0) = 0, except in ROUND_FLOOR rounding mode.
1153 if context.rounding == ROUND_FLOOR and self._sign != other._sign:
1166 ans = other._rescale(exp, context.rounding)
1171 ans = self._rescale(exp, context.rounding)
1339 # result is not exact; adjust to ensure correct rounding
1367 self._rescale(ideal_exp, context.rounding))
1517 ans = self._rescale(ideal_exponent, context.rounding)
1691 rounding_method = self._pick_rounding_function[context.rounding]
1700 # check whether the rounding pushed the exponent out of range
1732 # for each of the rounding functions below:
1812 Returns self*other+third with no rounding of the intermediate
1815 self and other are multiplied together, with no rounding of
1817 and a single final rounding is performed.
2232 # negate self, without doing any unwanted rounding
2340 # rounding mode; no need to switch to ROUND_HALF_EVEN here
2422 def quantize(self, exp, rounding=None, context=None, watchexp=True):
2431 if rounding is None:
2432 rounding = context.rounding
2447 ans = self._rescale(exp._exp, rounding)
2472 ans = self._rescale(exp._exp, rounding)
2508 def _rescale(self, exp, rounding):
2510 or by truncating digits, using the given rounding mode.
2517 rounding = rounding mode
2530 # exp-1, replace self by 10**(exp-1) before rounding
2535 this_function = self._pick_rounding_function[rounding]
2542 def _round(self, places, rounding):
2544 significant figures, using the given rounding mode.
2556 ans = self._rescale(self.adjusted()+1-places, rounding)
2558 # for example when rounding 99.97 to 3 significant figures.
2562 ans = ans._rescale(ans.adjusted()+1-places, rounding)
2565 def to_integral_exact(self, rounding=None, context=None):
2568 If no rounding mode is specified, take the rounding mode from
2586 if rounding is None:
2587 rounding = context.rounding
2588 ans = self._rescale(0, rounding)
2594 def to_integral_value(self, rounding=None, context=None):
2598 if rounding is None:
2599 rounding = context.rounding
2608 return self._rescale(0, rounding)
2644 # To ensure correct rounding in all cases, we use the
2646 # place (precision p+1 instead of precision p), rounding down.
2706 rounding = context._set_rounding(ROUND_HALF_EVEN)
2708 context.rounding = rounding
2999 # rounding mode, not just with ROUND_HALF_EVEN
3001 rounding = context._set_rounding(ROUND_HALF_EVEN)
3003 context.rounding = rounding
3133 rounding = context._set_rounding(ROUND_HALF_EVEN)
3135 context.rounding = rounding
3194 # answer may need rounding
3214 rounding = context._set_rounding(ROUND_HALF_EVEN)
3216 context.rounding = rounding
3678 # round if necessary, taking rounding mode from the context
3679 rounding = context.rounding
3683 self = self._round(precision+1, rounding)
3685 self = self._rescale(-precision, rounding)
3687 self = self._round(precision, rounding)
3691 self = self._rescale(0, rounding)
3767 prec - precision (for use in rounding, division, square roots..)
3768 rounding - rounding type (how you round)
3782 def __init__(self, prec=None, rounding=None,
3795 self.rounding = rounding if rounding is not None else dc.rounding
3823 s.append('Context(prec=%(prec)d, rounding=%(rounding)s, '
3839 nc = Context(self.prec, self.rounding, self.traps,
3846 nc = Context(self.prec, self.rounding, self.traps.copy(),
3904 """Sets the rounding type.
3906 Sets the rounding type, and returns the current (previous)
3907 rounding type. Often used like:
3912 rounding = context._set_rounding(ROUND_UP)
3914 context._set_rounding(rounding)
3918 rounding = self.rounding
3919 self.rounding= type
3920 return rounding
3940 """Creates a new Decimal instance from a float but rounding using self
3943 >>> context = Context(prec=5, rounding=ROUND_DOWN)
3954 return d._fix(self) # Apply the context rounding
4294 multiplication, using add, all with only one final rounding.
5049 operand. It may be rounded using the current rounding setting (if the
5363 are allowed in this operation. The rounding mode is taken from the
5393 be set. The rounding mode is taken from the context.
5459 # Then adding 10**exp to tmp has the same effect (after rounding)
5768 # rounding down
5860 prec=28, rounding=ROUND_HALF_EVEN,
5874 prec=9, rounding=ROUND_HALF_UP,
5880 prec=9, rounding=ROUND_HALF_EVEN,