重定数字的转换 [英] Reagarding conversion of numbers
问题描述
我正在为Windows手机和桌面写一个板球应用程序我也有小查询我需要计算运行率,但我面临转换十进制到int和我需要十进制值到int数。请参考下面的逻辑和示例
运行所需的运行
------------------------------ x 6 =所需的运行率
球剩余
例如,需要43次跑才能赢得4.2分。
然后需要运行率将是: -
运行所需的运行= 43
剩余球= 4.2超过=(4 x 6)+ 2 = 26球
运行需要赢得
------------ ------------------ x 6 =所需的运行率
球剩余
43
---- x 6 = 9.92
26
Hi,
I am writting one cricket app for windows phone and desktop also i have small query its i need to calculate the run rate but i am facing in the conversion decimal to int and i need that decimal value to int number.Please refer the below logic and example
Runs required to win
------------------------------ x 6 = Required run rate
Balls Remaining
For example 43 runs are required to win in 4.2 overs.
Then Required run rate would be:-
Runs required to win = 43
Balls Remaining = 4.2 overs = (4 x 6) + 2 = 26 balls
Runs required to win
------------------------------ x 6 = Required run rate
Balls Remaining
43
---- x 6 = 9.92
26
推荐答案
假设你想要一个十进制运行鼠e(9.92)转换为最接近的整数:
Assuming that you want a decimal run rate (9.92) converted up to the nearest integer:
Decimal precise = 9.92M;
int roundedUp = (int)Math.Ceiling(precise);
这篇关于重定数字的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!