PHP 에서 ceil, floor, round 의 차이점 > 개발

본문 바로가기
사이트 내 전체검색

개발

PHP 에서 ceil, floor, round 의 차이점

페이지 정보

profile_image
작성자 관리자 (61.♡.12.126)
댓글 0건 조회 4,543회 작성일 16-08-05 14:03

본문

PHP 에서 ceil(), floor(), round() 는 각각 소수점 이하 올림, 버림, 반올림 하는 함수이다.


<?php

// 기본 사용법

float ceil ( float value)  // 소수점 이하 올림
float floor ( float value)  // 소수점 이하 버림
float round ( float value)  // 소수점 이하 반올림


// 예제

floor  // 버림
floor(4.3);  // 4
floor(9.999); // 9

ceil  // 올림
ceil(4.3);    // 5
ceil(9.999);  // 10

round  // 반올림
round(3.4);        // 3
round(3.5);        // 4
round(3.6);        // 4
round(3.6, 0);      // 4
round(1.95583, 2);  // 1.96
round(1241757, -3); // 1242000
round(5.045, 2);    // 5.05
round(5.055, 2);    // 5.06

?>


** 출처 : http://happyjung.com/bbs/board.php?bo_table=lecture&wr_id=1147

추천0

댓글목록

등록된 댓글이 없습니다.

Total 386건 5 페이지
  • RSS
개발 목록
번호 제목 조회 추천 날짜
3063113004-29
3052312004-29
3042233004-29
3032972004-28
3022624004-28
3014114004-28
3002079004-25
2993179004-22
2981975004-14
2972451004-14
2962464004-12
2953463004-11
2942348004-07
2933131004-07
2923414003-25
2913519003-24
2903362003-06
2892413003-06
2882425003-01
2871785002-27

검색


사이트 정보

Copyright © Baragi.Net. All rights reserved.