math.py 261 B

1234567891011121314
  1. # -*- coding: utf-8 -*-
  2. import math
  3. import numpy as np
  4. def round_half_up(n: float, decimals: int = 0) -> float:
  5. if np.isnan(n):
  6. return n
  7. else:
  8. multiplier = 10 ** decimals
  9. return math.floor(n * multiplier + 0.5) / multiplier