Absolute Value and Casting to Round
Assume double dnum has been correctly declared and initialized with a valid value. What is the correct way to find its absolute value, rounded to the nearest integer?
Assume double dnum has been correctly declared and initialized with a valid value. What is the correct way to find its absolute value, rounded to the nearest integer?
A
(int) Math.abs(dnum + 0.5)
B
Math.abs((int)dnum - 0.5)
C
(int) (Math.abs(dnum) + 0.5)
D
(int) Math.abs(dnum - 0.5)
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | braydenchoi1111 | 1 | 1 | 0m 00s | 100 |
| #2 | aaaa1 | 0 | 1 | 0m 01s | -11 |
| #3 | demosolasis1 | 0 | 1 | 0m 52s | -62 |
| #4 | parth.taur227 | 0 | 1 | 1m 03s | -73 |
| #5 | richa.tuli | 1 | 1 | 4m 03s | -143 |
| #6 | lsj08030922 | 1 | 3 | 2h 13m | -7,927 |
Items per page:
10
1 – 6 of 6
APFIVE