2:14 am - Tuesday April 23, 2019

Math Example Program for copySign(double magnitude,double sign)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
 * @author: candidjava
 * @description: Math copySign(double magnitude, double sign) method. this
 *               method is used to copy the sign in sign value to magnitude
 *               value.
 */
public class CopySign {
	public static void main(String[] args) {
		double magnitude = 25.0, sign = -5.0;
		// get two double values
		System.out.println("before sign the values \t" + magnitude + "\t"
				+ sign);
		// to print before change the sign
		double d = Math.copySign(magnitude, sign);
		// this method is used to change magnitude sign same as the sign's
		// sign
		System.out.println("after sign the values\t" + sign + "\t" + d);
		// to print after change the sign
	}
}

Output:
before sign the values 25.0 -5.0
after sign the values -5.0 -25.0

Filed in: Z-A All Java Codes

Comments are closed.