Math. Floor and math. Ceil Functions

Source: Internet
Author: User
Public class ceilandfloor {
Public static void main (string [] ARGs ){
/*
The main task of these two functions is to cut off the digits after decimal places.
The difference is that floor always keeps the number smaller, while Ceil always increases the number.
In fact, the name can be understood as floor is the floor, and ceil is the ceiling.
*/
System. out. println ("================= math. floor () ================ ");
System. Out. println ("math. Floor (99.1) =" + math. Floor (99.1 ));
System. Out. println ("math. Floor (-99.1) =" + math. Floor (-99.1 ));
System. Out. println ("math. Floor (99.9) =" + math. Floor (99.9 ));
System. Out. println ("math. Floor (-99.9) =" + math. Floor (-99.9 ));
System. out. println ("\ n ================= math. ceil () ================ ");
System. Out. println ("math. Ceil (99.1) =" + math. Ceil (99.1 ));
System. Out. println ("math. Ceil (-99.1) =" + math. Ceil (-99.1 ));
System. Out. println ("math. Ceil (99.9) =" + math. Ceil (99.9 ));
System. Out. println ("math. Ceil (-99.9) =" + math. Ceil (-99.9 ));
}
}
Result
================= Math. Floor () ========================
Math. Floor (99.1) = 99.0
Math. Floor (-99.1) =-100.0
Math. Floor (99.9) = 99.0
Math. Floor (-99.9) =-100.0
=============== Math. Ceil () ==========================
Math. Ceil (99.1) = 100.0
Math. Ceil (-99.1) =-99.0
Math. Ceil (99.9) = 100.0
Math. Ceil (-99.9) =-99.0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.