1 / 9

การจัดการตัวเลข

การจัดการตัวเลข. ธี ระ พงษ์ แสงรักษาวงศ์. การปัดเศษทศนิยม. ceil() ปัดเศษทศนิยมขึ้นทุกกรณี floor() ปัดเศษทศนิยมทิ้งทุกกรณี round() ปัดเศษทศนิขึ้น กรณีที่มีค่าตั้ง แต่ 5 ขึ้นไป ส่วนค่าน้อยกว่า 5 ปัดทิ้ง. การปัดเศษทศนิยม. ceil(4.3) ceil(9.9999) ceil(-3.14) floor(4.3) floor(9.9999)

amity
Download Presentation

การจัดการตัวเลข

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. การจัดการตัวเลข ธีระพงษ์ แสงรักษาวงศ์

  2. การปัดเศษทศนิยม • ceil() ปัดเศษทศนิยมขึ้นทุกกรณี • floor() ปัดเศษทศนิยมทิ้งทุกกรณี • round() ปัดเศษทศนิขึ้น กรณีที่มีค่าตั้ง แต่ 5 ขึ้นไป ส่วนค่าน้อยกว่า 5 ปัดทิ้ง

  3. การปัดเศษทศนิยม ceil(4.3) ceil(9.9999) ceil(-3.14) floor(4.3) floor(9.9999) floor(-3.14) round(4.3) round(9.9999) round(1.9558,2) round(5.045)

  4. การจัดรูปแบบตัวเลข • number_format() ใช้จัดรูปแบบตัวเลข โดยใช้เครื่องหมาย. คั่นระหว่างทศนิยมกับจำนวนเต็ม ใช้เครื่องหมาย , แบ่งตัวเลขหลักพัน เช่น 1,854,800.50 นอกจากนี้ยังเปลี่ยนเครื่องหมายเหล่านี้ได้ตามต้องการ รวมทั้งกำหนดให้แสดงทศนิยมกี่ตำแหน่งก็ได้

  5. การจัดรูปแบบตัวเลข รูปแบบ string number_format(float val(,intdecimals[,string dec_point,stringthousands_sep]]); • decimals คือ จำนวนทศนิยมที่ต้องการ • dec_pointคือ เครื่องหมายที่ใช้แสดงว่าหลังจากเครื่องหมายนี้คือทศนิยม( default -> . ) • thousands_sepคือ เครื่องหมายแบ่งตัวเลขหลักพัน (default -> ,)

  6. การจัดรูปแบบตัวเลข $num = 3957.7398; echo $num; echo number_format($num); echo number_format($num,2); echo number_format(12345.334,2,'*','#');

  7. การแปลงเลขฐาน base_convert() ใช้แปลงตัวเลขระหว่างเลขฐานต่าง ๆ decbin() ใช้แปลง เลขฐานสิบ เป็น เลขฐานสอง bindec() ใช้แปลง เลขฐานสอง เป็น เลขฐานสิบ decoct()ใช้แปลง เลขฐานสิบ เป็นเลข เลขฐานแปด octdec() ใช้แปลง เลขฐานแปด เป็น เลขฐานสิบ dechex() ใช้แปลง เลขฐานสิบ เป็น เลขฐานสิบหก hexdec() ใช้แปลง เลขฐานสิบหก เป็น เลขฐานสิบ

  8. การแปลงเลขฐาน $num = 1234; decbin($num); decoct($num); dechex($num); bindec(1011001); 10011010010 2322 4d2 89

  9. การยกกำลัง • pow(base,exp) • base -> เลขฐาน • exp -> จำนวนที่ต้องการยกกำลัง echo pow(2,2); -> echo pow(2,3); -> echo pow(10,2); -> echo pow(3,2); ->

More Related