© Doug Winnie 2021
D. WinnieEssential Java for AP CompScihttps://doi.org/10.1007/978-1-4842-6183-5_19

19. Math Methods

Doug Winnie1  
(1)
Mission Hills, KS, USA
 

Basic math operators will only get you so far. There are a bunch more that you can use to do things with more advanced methods like algebra, trigonometry, statistics, calculus, and more in Java.

Working with Simple Methods

The most basic is working with numbers and rounding them. There are three ways to deal with a decimal value on a number.

The first is to just eliminate it entirely. This is called finding the number’s floor. Any decimal value is simply removed. Even if it is .99999.

The second is to take any decimal value and raise it up to the next whole number, called the number’s ceiling. ...

Get Essential Java for AP CompSci: From Programming to Computer Science now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.