怎么总是四舍五入到下一个整数 [英] how to always round up to the next integer

查看:159
本文介绍了怎么总是四舍五入到下一个整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到总页数在网站上建立一个寻呼机(所以我希望得到的结果是一个整数,我得到一个记录列表,我想分成10每页(页数)



当我这样做:

  list.Count()/ $ 10 b $ b  

  list.Count()/(十进制)10 

list.Count()= 12 ,我得到 1 的结果。



如何将我的代码,所以我得到 2 在此情况下(其余应随时添加 1


解决方案

  Math.Ceiling((双)list.Count()/ 10); 


i am trying to find total pages in building a pager on a website (so i want the result to be an integer. i get a list of records and i want to split into 10 per page (the page count)

when i do this:

list.Count() / 10

or

list.Count() / (decimal)10

and the list.Count() =12, i get a result of 1.

How would I code it so i get 2 in this case (the remainder should always add 1)

解决方案

Math.Ceiling((double)list.Count() / 10);

这篇关于怎么总是四舍五入到下一个整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆