반올림 함수 round()

Jmnote (토론 | 기여)님의 2014년 5월 2일 (금) 15:29 판 (새 문서: Category:Math *Rounds a float *round *number_format ==Java== Category:Java <source lang='java'> int i = Math.round(1.5F); // 2 </source> <source lang='java'> String str = Str...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)
  • Rounds a float
  • round
  • number_format

1 Java

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

2 JavaScript

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

3 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

4 SQL

4.1 MySQL

SELECT ROUND(2.71828, 2);
-- 2.72

4.2 PostgreSQL

5 같이 보기

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