Java mathematical functions common methods in math class __ function

Source: Internet
Author: User
Tags abs cos mathematical functions pow root math sin square root

The Math class provides a number of commonly used mathematical functions, such as trigonometric, logarithmic, exponential, and so on. A mathematical formula if you want to represent it in code, you can split it and then apply the method under the Math class.

		
		Math.Abs (12.3);				12.3 Returns the absolute value of this number Math.Abs (-12.3);		12.3 Math.copysign (1.23,-12.3);		-1.23, returns the measure of the first parameter and the symbol math.copysign (-12.3, 1.23) of the second parameter;					12.3 Math.signum (x);				If x is greater than 0, then returns 1.0, less than 0 returns-1.0, or 0 returns 0 Math.signum (12.3);				1.0 math.signum (-12.3);					-1.0 math.signum (0);					0.0//Index MATH.EXP (x);					X power MATH.EXPM1 (x) of E;				x power of E-1 math.scalb (x, y);			x* (y power of 2) Math.scalb (12.3, 3);				12.3*2³//the whole Math.ceil (12.3);				Returns the nearest integer 13.0 Math.ceil (-12.3) that is greater than this number;				-12.0 Math.floor (12.3);				Returns the nearest integer 12.0 Math.floor (-12.3) that is less than this number;				-13.0//x and y squared sum of two square root math.hypot (x, y);					√ (x²+y²)//Returns an overview of the two square root math.sqrt (x);					√ (x) x two square root math.sqrt (9);					3.0 math.sqrt (16);				4.0//Returns the cubic root math.cbrt (27.0) of the number;				3 MATH.CBRT (-125.0);					-5//Logarithmic function Math.log (e);				1 logarithm math.log10 (100) with the e as the base;					10 logarithmic math.log1p (x) with a 10 base; Ln (x+ 1)//returns a larger value and a smaller value Math.max (x,y);					Returns the larger number math.min (x, y) in X and y;					
		Returns the smaller number in X, Y//returns the Y-power Math.pow (x, y) of X;					Math.pow (2, 3);					
		
		That is, 2³ returns: 8//random return of the unsigned Double value math.random () between [0,1];				Returns the integer closest to this number, or even math.rint (12.3) If it is just centered;				12.0 Math.rint (-12.3);				-12.0 Math.rint (78.9);				79.0 Math.rint (-78.9);				-79.0 Math.rint (34.5);				34.0 Math.rint (35.5);				36.0 Math.Round (12.3);					Similar to Rint, the return value is long//trigonometric Math.sin (alpha);					The value of sin (α) math.cos (Alpha);					The value of cos (α) is Math.tan (alpha);					Tan (α) value//Angle Math.asin (x/z);					Returns the angle value [-Π/2,Π/2] arc sin (x/z) math.acos (y/z);					Returns the angular value [0~π] arc cos (y/z) Math.atan (y/x); 		Returns the angle value [-Π/2,Π/2] math.atan2 (y-y0, x-x0);					Ibid., returns the angle between the line between the point (X,y) and the origin and the line between the point (X0,y0) and the Origin Math.sinh (x);
		Hyperbolic sine function sinh (x) = (exp (x)-exp (-X))/2.0;					Math.cosh (x);
		Hyperbolic cosine function cosh (x) = (exp (x) + exp (-X))/2.0;					Math.tanh (x);
		
		Tanh (x) = Sinh (x)/cosh (x);			Angle Radian Interchange Math.todegrees (Angrad); Angle converted to radians, return: Angrad * 180d/pi Math.toradians (angdeg);
		 Radians converted to angles, back: angdeg/180d * PI


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.