Solved

Prevent Rounding of numbers

Posted on 2013-11-22
2
238 Views
Last Modified: 2013-11-22
I have the following code that shows me a value of 4.0, but I know that is wrong. When I calculate 1791 / 365 I get 4.906849315068493. My value shows up at 4.0. At the least I would like it to calculate out to 5.0. Still it would be nice to see 4.90. What am I doing wrong?

                Int32 bb = (Int32)DataBinder.Eval(e.Row.DataItem, "DAYS"); // This value calculates to 1791
                double cc = bb / 365;
                lbl.Text = cc.ToString();

Open in new window

0
Comment
Question by:NickMalloy
  • 2
2 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 350 total points
Comment Utility
Does this help.  (You were dividing two integers before)
double cc = bb / 365.0;
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
ps.  You might also want ToString("0.00"); if you wanted it formatting to 2 decimal places.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now