round(x,y)和format(x,y)

Posted bibiafa

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了round(x,y)和format(x,y)相关的知识,希望对你有一定的参考价值。

select round(123456.1456,2);
+----------------------+
| round(123456.1456,2) |
+----------------------+
|            123456.15 |
+----------------------+

select format(123456.1456,2);
+-----------------------+
| format(123456.1456,2) |
+-----------------------+
| 123,456.15            |
+-----------------------+

round()和format()都会对数值进行四舍五入,但是format()返回的是字符串,整数部分,每3位添加一个逗号。round()返回的仍然是数值

以上是关于round(x,y)和format(x,y)的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #635 (Div. 2) AIchihime and Triangle

ROUND(x,y)

DIV_ROUND_UP(x,y)实现x/y向上取整

Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) C. Ordering Pizza

Codeforces Round #561 (Div. 2)

plt.plot(x,y,format_string,**kwargs)