-
June 22nd, 2012, 09:34 AM
#1
How can I round this Convert.ToInt64 number that will be returned
Hello,
I need to have this number rounded and have never done this before, so If you can help me that would be great.
long mem1 = Convert.ToInt64(objPartition["Size"].ToString()) / 1024 / 1024 / 1024 + 0;
Currently it is reporting 3GB and should be 4GB
So this number must be close to 3.xxxx and need to be round up to 4.xx
I found this on msdn, but dont understand how to make it work with my line of code.
Math.Round(3.44, 1); //Returns 3.4.
Math.Round(3.45, 1); //Returns 3.4.
Math.Round(3.46, 1); //Returns 3.5.
Thanks for your help,
-Mike
-
June 22nd, 2012, 12:19 PM
#2
Re: How can I round this Convert.ToInt64 number that will be returned
If you change ", 1);" to ", 0);" your examples will all return 3.
-
July 3rd, 2012, 09:16 PM
#3
Re: How can I round this Convert.ToInt64 number that will be returned
Are you trying to round up? You could always use Math.Ceiling.
See the below link, http://msdn.microsoft.com/en-us/library/zx4t0t48.aspx.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|