File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rouding up a number

 
Dave Mere
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

As part of my pagination efforts, I need to round up a number to work out how many pages I need. So, where results is my ArrayList:



This outputs;
18
1.0
1.0

So 18 records returned (ok). The divide by 10 . . . = 1.0? What's going on?

How can I round up 18/10? Or generally work out how many pages I need for my 18 record resultset?

thanks!

Dave
 
Sam Bluesman
Ranch Hand
Posts: 191
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.coderanch.com/t/402346/java/java/Rounding-up

I had that problem
 
Dave Mere
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorted! Cheers Sam.

And on that note, I'm off to the pub . . .
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For some reason I did a bunch of these in the waning days of my COBOL life, and just added divisor-1 before dividing. This linecount and pagecount case came up for a character mode help system. For ints:

pagecount = ( linecount + linesperpage - 1 ) / linesperpage
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic