{"id":133,"date":"2023-08-01T16:59:29","date_gmt":"2023-08-01T08:59:29","guid":{"rendered":"https:\/\/jiachen.de.cool\/blog\/?p=133"},"modified":"2023-08-02T16:43:33","modified_gmt":"2023-08-02T08:43:33","slug":"%e8%8e%b7%e5%8f%96%e6%95%b4%e6%95%b0%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/jiachen.de.cool\/blog\/2023\/08\/01\/%e8%8e%b7%e5%8f%96%e6%95%b4%e6%95%b0%e5%87%bd%e6%95%b0\/","title":{"rendered":"\u83b7\u53d6\u6574\u6570\u51fd\u6570"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">1\u3001\u8fd4\u56de\u5927\u4e8e\u6216\u7b49\u4e8e\u6570\u503cx\u7684\u6700\u5c0f\u6574\u6570<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bed\u6cd5\uff1a<code>ceil(x);<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql> select ceil(4.3),ceil(-2.5);\n+-----------+------------+\n| ceil(4.3) | ceil(-2.5) |\n+-----------+------------+\n| 5 | -2 |\n+-----------+------------+\n1 row in set (0.01 sec)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u8fd4\u56de\u5c0f\u4e8e\u6216\u7b49\u4e8e\u6570\u503cx\u7684\u6700\u5927\u6574\u6570<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bed\u6cd5\uff1a<code>floor(x);<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql> select floor(4.3),floor(-2.5);\n+------------+-------------+\n| floor(4.3) | floor(-2.5) |\n+------------+-------------+\n| 4 | -3 |\n+------------+-------------+\n1 row in set (0.00 sec)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3\u3001\u622a\u53d6\u6570\u503c\u51fd\u6570<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bed\u6cd5\uff1a<code>truncate(x,y);<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd4\u56de\u6570\u503cx\uff0c\u4fdd\u7559\u5c0f\u6570\u70b9\u540ey\u4f4d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql> select truncate(999.345,2),truncate(999.345,-1);\/*\u4e0d\u56db\u820d\u4e94\u5165*\/\n+---------------------+----------------------+\n| truncate(999.345,2) | truncate(999.345,-1) |\n+---------------------+----------------------+\n| 999.34 | 990 |\n+---------------------+----------------------+\n1 row in set (0.00 sec)\n\nmysql> select truncate(999.345,2),truncate(999.999,-1);\n+---------------------+----------------------+\n| truncate(999.345,2) | truncate(999.999,-1) |\n+---------------------+----------------------+\n| 999.34 | 990 |\n+---------------------+----------------------+\n1 row in set (0.00 sec)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">4\u3001\u56db\u820d\u4e94\u5165\u51fd\u6570<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bed\u6cd5\uff1a<code>round(x);<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u51fd\u6570\u8fd4\u56de\u503cx\u7ecf\u8fc7\u56db\u820d\u4e94\u5165\u64cd\u4f5c\u540e\u7684\u6570\u503c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql> select round(999.999);\/*\u53d6\u6574*\/\n+----------------+\n| round(999.999) |\n+----------------+\n| 1000 |\n+----------------+\n1 row in set (0.00 sec)\n\nmysql> select round(903.5),round(-903.4);\/*\u53d6\u6574*\/\n+--------------+---------------+\n| round(903.5) | round(-903.4) |\n+--------------+---------------+\n| 904 | -903 |\n+--------------+---------------+\n1 row in set (0.00 sec)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bed\u6cd5\uff1a<code>round(x,y);<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd4\u56de\u6570\u636ex\u4fdd\u7559\u5230\u5c0f\u6570\u70b9\u540ey\u4f4d\u7684\u503c\uff0c\u5728\u5177\u4f53\u622a\u53d6\u6570\u636e\u65f6\u9700\u8981\u8fdb\u884c\u56db\u820d\u4e94\u5165\u7684\u64cd\u4f5c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql> select round(903.53,2),round(903.54,-1);\n+-----------------+------------------+\n| round(903.53,2) | round(903.54,-1) |\n+-----------------+------------------+\n| 903.53 | 900 |\n+-----------------+------------------+\n1 row in set (0.00 sec)\n\nmysql> select round(903.54,0);\n+-----------------+\n| round(903.54,0) |\n+-----------------+\n| 904 |\n+-----------------+\n1 row in set (0.00 sec)\n\nmysql> select truncate(903.54,0);\n+--------------------+\n| truncate(903.54,0) |\n+--------------------+\n| 903 |\n+--------------------+\n1 row in set (0.00 sec)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u8fd4\u56de\u5927\u4e8e\u6216\u7b49\u4e8e\u6570\u503cx\u7684\u6700\u5c0f\u6574\u6570 \u8bed\u6cd5\uff1aceil(x); 2\u3001\u8fd4\u56de\u5c0f\u4e8e\u6216\u7b49\u4e8e\u6570\u503cx\u7684\u6700\u5927\u6574\u6570 \u8bed\u6cd5\uff1afloo&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/jiachen.de.cool\/blog\/2023\/08\/01\/%e8%8e%b7%e5%8f%96%e6%95%b4%e6%95%b0%e5%87%bd%e6%95%b0\/\">Read the full article<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[31,30],"class_list":["post-133","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-31","tag-30"],"_links":{"self":[{"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/posts\/133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/comments?post=133"}],"version-history":[{"count":3,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/posts\/133\/revisions"}],"predecessor-version":[{"id":136,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/posts\/133\/revisions\/136"}],"wp:attachment":[{"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/media?parent=133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/categories?post=133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/tags?post=133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}