Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind Java Math copySign() Method?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
1Quick choice
Which statement best captures the main point of this lesson?
2Fill blank
Complete the missing token from the example code.
___.out.println(Math.copySign(-4.7, 3));3Order
Put the learning moves in the order that makes the concept easiest to apply.
The copySign() method returns the value of the first number with the sign of the second number.
Definition and Usage
Java Math copySign() Method
❮ Math Methods
Example
System.out.println(Math.copySign(-4.7, 3));
System.out.println(Math.copySign(4.7, -2.5));
System.out.println(Math.copySign(3, 4));
System.out.println(Math.copySign(-2.5, -4.7));Definition and Usage
The copySign() method returns the value of the first number with the sign of the second number.
One of the following
public static double copySign(double
value , double
sign )public static float copySign(float
value , float
sign )Parameter Values
| Parameter | Description |
|---|---|
| value | Required. A number which determines the value. |
| sign | Required. A number which determines the sign. |
Technical Details
| Returns: | A double or float with the value of the first number and the sign of the second number. |
|---|---|
| Java version: | 1.6+ |