Click here to Skip to main content
11,433,220 members (60,742 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 Windows Mobile
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
Posted 5-Feb-13 2:51am
Edited 5-Feb-13 2:52am
v2
Comments
NaVeN Kumar at 5-Feb-13 7:57am
   
Do you need that conversion in C# or what?
Pete O'Hanlon at 5-Feb-13 7:59am
   
But what is your actual question? I can see that you understand what it is you are trying to achieve, but I can't see anything in there that states what problem you are having. What, exactly, is causing you an issue?
nagesh21 at 5-Feb-13 23:50pm
   
Hi Pete, see first i will take the overs left in one text box for example overs left is 4.3 by using this we cannot calculate the runrate so we do like this 4*6+3 it comes to 27balls remaining i need this should be done through in code any option is there.I tried with rounding off the value but i am not able to add the precision value after multiplying with 6.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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);
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.150428.2 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100