"반올림 함수 round()"의 두 판 사이의 차이

잔글 (Jmnote 사용자가 함수 round 문서를 함수 round() 문서로 옮겼습니다)
28번째 줄: 28번째 줄:


==PHP==
==PHP==
{{참고|PHP round()}}
{{참고|PHP number_format()}}
[[Category:PHP]]
[[Category:PHP]]
<source lang='php'>
<source lang='php'>

2015년 7월 13일 (월) 09:56 판

Rounds a float
round
number_format

1 Excel

=ROUND(3.14159,0) // 3
=ROUND(3.14159,2) // 3.14

2 Java

int i = Math.round(1.5F); // 2
String str = String.format("%.3f", 1.2345678); // 1.235

3 JavaScript

console.log( Math.round(10.6) ); // 11

4 PHP

echo round(7.4);         // 7
echo round(7.5);         // 8
echo round(7.6);         // 8
echo round(7.7, 0);         // 8
echo round(3.14159, 2);  // 3.14
echo number_format(9.98);  // 10
echo number_format(-9.98);  // -10
echo number_format(3.14159, 0);  // 3
echo number_format(3.14159, 2);  // 3.14
echo number_format(-3.14159, 0);  // -3
echo number_format(-3.14159, 2);  // -3.14

5 SQL

5.1 MySQL

SELECT ROUND(2.71828, 2);
-- 2.72

5.2 PostgreSQL

6 같이 보기

7 참고 자료

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}