Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Marcio Almeida
4,579 PointsMath.round
Hi,
I'm trying to round a double number to an integer, and i'm doing like this
public double getWindSpeed() {
return (int)Math.round(35.23);
}
but I dont know why is returning "35.0" and not "35"
Thank you
1 Answer

Daniel Hartin
18,106 PointsHi Marcio
As the data type int doesn't support decimal numbers casting to an int will always results in a whole number. The problem is the method where you have defined it to return a double , if you change this to int you should be fine.
Hope this helps Daniel
Marcio Almeida
4,579 PointsMarcio Almeida
4,579 PointsHi,
The problem is not with the method, I dont now why in my activity always show a decimal number.