This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Number generation

 
michael yue
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I dont know how to come up with the simplest algorithm for this problem.
I want to generate a range of numbers if the front of the numbers begin with 0.
Example start number is 001 and end number is 008
then it will generate 001,002,003 and so on till 008.

Also i am a bit stumped on preventing wrong input generation for example when first number input 001 but end number input 0005.
Thanks a lot. Hope i am clear enough.
 
Mark Patrick
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the API specification for java.text.DecimalFormat.
 
Mark Patrick
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This will do the trick:

 
I'm not dead! I feel happy! I'd like to go for a walk! I'll even read a tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!