Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

converting double to int?  RSS feed

 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do i convert a double number, which I'm sure to be a whole number (due to a rounding operator i have used) back to an integer? Is this possible?

I keep getting a 'possible loss of precision error'. I understand why this may be the case in other circumstances but I know this wouldn't hapen in my case.
 
Megs Maquito
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have to explicitly cast a double to an int. This will tell the JVM that yes you do understand that there will be a loss in precision.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!