Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

DelphiRoundingMode

Delphi rounding mode

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

ทำความเข้าใจเกี่ยวกับการปัดจุดทศนิยมบน Delphi

ปัญหา การปัดเศษ บน Delphi

ใส่ A = 11291.50 กดปุ่ม 7% -> 11291.50 x 0.07 = 790.41 <- ค่าที่ถูกต้อง

  • แต่โปรแกรมโชว์ 790.40 ตามโปรแกรมนี้ B = 790.40

Grand Total C = A + B ( 11291.50 + 790.40 ) ต้องได้ค่า = 12,081.90

  • แต่โปรแกรมโชว์ 12,081.91 กดปุ่ม 1% -> 11291.50 x 0.01 = 112.92 <- ค่าที่ถูกต้อง ครั้งนี้ปัดถูก

NET Pay E = C - D (12081.91 - 112.92) = 11968.99 <- ค่าถูกต้อง

ปัญหาคือ ทำไมตอน กด 7% คือ 11291.50 x 0.07 = 790.405 ทำไมไม่ปัดขึ้นเป็น 790.41

แต่ ตอนกด 1% คือ 11291.50 x 0.01 = 112.915 ถึงปัดขึ้นเป็น 112.92

===============================================================