Rounding Challenge in Java: double value = 6.283
Math.floor(6.283) = 6.0
Math.ceil(6.283) = 7.0
1 decimal place: Math.round(6.283 * 10) / 10.0 = 6.3
2 decimal places: Math.round(6.283 * 100) / 100.0 = 6.28
Floor: 6
Ceiling: 7
Round 1P: 6.3
Round 2P: 6.28
Hey guys - Just a note that the audio on the video (and caption) asks us to “find the number to 1 and 2 decimal places”, should probably clearly state that “find” means to “round” it. I’d never heard that.
Anywho - my answers are:
- Floor: 6
- Ceil: 7
- Rounding: 6.3 and 6.28
6[/spoiler] is the floor, 7 is the ceiling. Rounded to one decimal place it is 6.3, To two decimal places it is [spoiler]6.28
The round function in C math only takes one argument though, so it seems to work pretty much as the ceiling function?
6
7
6.3
6.28
So here is my answer.
Floor value for 6.283 is 6
Ceiling value for 6.283 is 7
Round value to 1 decimal of 6.283 is 6.28
Round value to 2 decimal of 6.283 is 6.3
Number: 6.283
Floor: 6.0
Ceiling: 7.0
Round to 1 place: 6.3
Round to 2 place: 6.28
Floor: 6
Ceil: 7
1 DP: 6
2 DP: 6.3
Stsrt: 6.238
Floor whole number: 6
Floor 2 decimals: 6.23
Ceiling whole number: 7
Ceiling 2 decimals: 6.24
Your challenge is to take the number 6.283 and:
- Find the Floor of the number: 6
- Find the Ceiling of the number: 7
- Round the number to both 1 & 2 decimal places.: 6.3, 6.28
n = 6.283
Floor(n) = 6
Ceiling(n) = 7
Round(n,1) = 6.3
Round(n,2) = 6.28
Floor (6.283) = 6
Ceil (6.283) = 7
Math.Round (6.283, 1) = 6.3
Math.Round (6.283, 2) = 6.28
- 6
- 7
- 6.3 (1 dp) and 6.28 (2 dp)
Floor: 6.0
Ceiling: 7.0
Round to 1: 6.3
Round to 2: 6.28