473,386 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Formatting a 'double' type object..

3
double tmin, minmax = 0;

Stopwatch timer = new Stopwatch();

timer.Start();
...
timer.Stop();

tmin = timer.Elapsed.TotalMinutes

minmax += tmin;

timer.Reset();

Let's say there are about 3 loops, which would normaly result in a 'double' type value of 'minmax' at something 3.593xxx

I want to output the value of 'minmax' on-screen with only the numbers BEFORE the "." symbol..

This is what i tried to use:

Console.WriteLine("Total Minutes: {0:F0", minmax)

But it would only result in an appromaximate '~' conversion of the whole value before the "." sign - meaning IF there is a anything <5 after the dot, then i will get a 1 point higher value overall, hence .5 (in this example i would've gotten a '4', instead of a 3, which is what i need)

I tried to convert minmax to a string and then simply removing anything after the "." sign, but that didn't work either, since sometimes minmax IS actually a 0, but declaring minmax initialy as 0.0 and keeping it's value as 0.0 is not possible, since the compiler simply assigns a single 0 to it.. WHICH means, that i am going to get an error, when trying to remove pointless chars with a command of this syntax - string.Remove(string.IndexOf(".")), since there is no dot (.) present..

Any ideas?
Jan 14 '07 #1
2 1213
kenobewan
4,871 Expert 4TB
Have you tried math.floor? This should round the number down for you.

Hope that this helps.
Jan 14 '07 #2
esoj
3
Have you tried math.floor? This should round the number down for you.

Hope that this helps.
Thanks, it does just that!
Jan 15 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Josh Harris | last post by:
Here is my issue: I have a datagrid that is populated with a datatable. I want the columns of the datagrid to be sortable. I also want to format the numeric columns such as two decimal places...
2
by: John S | last post by:
I have created an event handler that is trying to format each number as it is typed. Example If the first char is 1 = output is $1.00 second char is 3 = output is $13.00 next is 5 = $135.00...
10
by: Perry van Kuppeveld | last post by:
Hi, I have a problem with formatting a table including text fields wich can contain up to 255 chars. I need a table with 3 columns: - First column 50 % over the with a rowspan of the total...
10
by: Coleen | last post by:
Hi all :-) I have a weird formatting problem with an HTML table that I am populating using VB.Net and HTML. Here is the snippet of code for the cell I'm trying to format: Dim...
42
by: xdevel | last post by:
Hi, if I have: int a=100, b = 200, c = 300; int *a = {&a, &b, &c}; than say that: int **b is equal to int *a is correct????
14
by: Scott M. | last post by:
Ok, this is driving me nuts... I am using VS.NET 2003 and trying to take an item out of a row in a loosely-typed dataset and place it in a label as a currency. As it is now, I am getting my...
17
by: scan87 | last post by:
Can somone please, please give me the solution for the following problem. I need to submit it on Monday. Write a global function called format, which formats numbers with a given number of decimal...
3
by: =?Utf-8?B?RGFycmVsbCBXZXNsZXk=?= | last post by:
1) Where can I find the valid set of formatting codes that can be used with the tostring method? 2) When using the following statement I get an invalid cast error --- why? X0SS =...
3
by: sparks | last post by:
We have one database that they are constantly reformatting their inputs. I asked about the changes and they can never get the same types of numbers from the people. some are -.95 and later they...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.