round_bankers

description

Syntax

T round_bankers(T x[, d])x使用银行家舍入法后,保留d位小数,d默认为0。如果d为负数,则小数点左边d位为0。如果xd为null,返回null。

  • 如果舍入数介于两个数字之间,则该函数使用银行家的舍入
  • 在其他情况下,该函数将数字四舍五入到最接近的整数。

example

  1. mysql> select round_bankers(0.4);
  2. +--------------------+
  3. | round_bankers(0.4) |
  4. +--------------------+
  5. | 0 |
  6. +--------------------+
  7. mysql> select round_bankers(-3.5);
  8. +---------------------+
  9. | round_bankers(-3.5) |
  10. +---------------------+
  11. | -4 |
  12. +---------------------+
  13. mysql> select round_bankers(-3.4);
  14. +---------------------+
  15. | round_bankers(-3.4) |
  16. +---------------------+
  17. | -3 |
  18. +---------------------+
  19. mysql> select round_bankers(10.755, 2);
  20. +--------------------------+
  21. | round_bankers(10.755, 2) |
  22. +--------------------------+
  23. | 10.76 |
  24. +--------------------------+
  25. mysql> select round_bankers(1667.2725, 2);
  26. +-----------------------------+
  27. | round_bankers(1667.2725, 2) |
  28. +-----------------------------+
  29. | 1667.27 |
  30. +-----------------------------+
  31. mysql> select round_bankers(1667.2725, -2);
  32. +------------------------------+
  33. | round_bankers(1667.2725, -2) |
  34. +------------------------------+
  35. | 1700 |
  36. +------------------------------+

keywords

  1. round_bankers