# 8 examples of 'python round float' in Python

Every line of 'python round float' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

## All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
``344def round_float(x):345    return round(x, 9)``
``20def roundFloat(f, error=1000000.):21	return round(f*error)/error``
``631def rpy_round(number, ndigits):632    # Algorithm copied directly from CPython633634    if number == 0 or rfloat.isinf(number) or rfloat.isnan(number):635        return number636637    # Deal with extreme values for ndigits. For ndigits > NDIGITS_MAX, x638    # always rounds to itself.  For ndigits < NDIGITS_MIN, x always639    # rounds to +-0.0.640    if ndigits > NDIGITS_MAX:641        return number642    elif ndigits < NDIGITS_MIN:643        # return 0.0, but with sign of x644        return 0.0 * number645646    # finite x, and ndigits is not unreasonably large647    z = rfloat.round_double(number, ndigits)648    if rfloat.isinf(z):649        raise OverflowError650    return z``
``312def p_round(n, precision=5):313    precision = int(precision)314    return int(round(n / float(precision))) * precision``
``367def _round(self, value):368    return value.quantize(self.exp)``
``57def roundFloat(floater):58    if floater - math.floor(floater) < 0.5:59        return int(math.floor(floater))60    else:61        return int(math.ceil(floater))``
``93def is_castable_to_float(obj):94    try:95        float(obj)96    except (ValueError, TypeError):97        return False98    return True``
``66def test_float(self):67    self.assertEqual(sqlrepr(10.01), "10.01")``