Solved

Prevent Rounding of numbers

Posted on 2013-11-22
2
242 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 44

Accepted Solution

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

Expert Comment

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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How come this regular expression allows "e"? 14 57
VB.NET 2008 - SQL Timeout 9 50
C# Formatting DateTime String Value 5 50
Header Font Size in Grid View 6 24
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

756 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