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

incrementing to next ten value  RSS feed

 
steve kelly
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sure there are a gazillion examples and a bunch of ways to do this. I was just finding something existing that does this. Basically, I want to increment to next 10 value no matter what the number is. Example if I have an int of 23 I want to return 30. If I have an int of 47 I want to return 50.
There has to be something out there does this already without playing with decimals and multiplying/rounding etc... right?
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recommend you write your own. Two lines, maybe one? Just think of the sense of accomplishment you'll have.
 
Edwin Torres
Ranch Hand
Posts: 57
Java Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg Brannon wrote:I recommend you write your own. Two lines, maybe one? Just think of the sense of accomplishment you'll have.

One:
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or with the solution provided by Edwin, you don't need to.
 
Edwin Torres
Ranch Hand
Posts: 57
Java Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:Edwin,

Please refrain from providing solutions. We prefer to help guide people to finding their own, rather than simply spoon feeding it to them.

Got it. Thanks.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!