Android Math Usage Encyclopedia

Source: Internet
Author: User
Tags natural logarithm pow square root


Java has a very useful tool class, you can less than a lot of if else to judge, but not many people use, published this article is intended to let many people use this tool class, improve code quality and force lattice

Math.PI returns the recorded pi


MATH.E returns the constant of record E


Math.Abs return Absolute Value


Math.sin return sine function math.asin inverse chord function


Math.Cos return cosine function math.acos inverse cosine function


Math.tan return tangent function Math.atan inverse tangent function   The inverse tangent function of the math.atan2 quotient


Math.todegrees return radian to angle Math.toradians angle to radians


Math.ceil returns the largest integer that is not less than a certain number

For example

Math.ceil (10.2) = 11;

Math.ceil (-10.2) =-10;


Math.floor returns the largest integer not greater than a number

For example

Math.floor (10.2) = 10;

Math.floor (-10.2) =-11;

Math.exp returns any of the second sides of E


MATH.LOG10 returns the logarithm with a 10 base


Math.log returns the natural logarithm


Math.rint returns the nearest integer from a number

For example:

Math.rint (10.5) = 10.0;

Math.rint (10.4) = 10.0;

Math.rint (10.6) = 11.0;


Math.Round rounding returns an int or a long type (the previous function returns a double type)


Math.random returns a random number between 0 and 1.


Math.ieeeremainder (x,y) return x%y value


Math.max returns the largest of the two numbers


Math.min returns the smallest of two digits


Math.sqrt return to Root


Math.pow returns a number of any secondary party

MATH.SQRT (x): Returns the square root
Math.pow (X,y): Returns the Y-second side of X

Math.nextdown (x) 0.00001 smaller than x

Math.nextup (x) 0.00001 larger than X

Math.addexact (1, 2); Addition operations

Math.subtractexact (3, 5); subtraction operation
Math.multiplyexact (2, 4); Multiplication operations

Math.scalb (6, 3); Represents 6 * (2 of 3)





Related Article

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.