Click here to Skip to main content
15,911,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to convert GB to Bytes without decimal point.
e.g 3.76 GB (4,047,660,432 bytes)
But actual calculated value is 4037269258.24
3.76*(1024*1024*1024)
Posted
Comments
Maarten Kools 5-Aug-13 6:42am    
Well, you could just use Math.Round[^]. But 4047660432 Bytes isn't exactly the same as 3.76 GB, the 3.76 is a rounded value in itself. You're never going to get the actual number of Bytes from it
Pheonyx 5-Aug-13 7:01am    
You cannot because you do not have the original value, you will only ever be able to approximately calculate the original value when your are working backwards from a rounded value.
Richard MacCutchan 5-Aug-13 9:40am    
You calculation is wrong: 4,047,660,432 is almost 3.77. Use the windows calculator to check the actual values.

1 solution

try this :

String f = Convert.ToString(Math.Round(Convert.ToDouble(3.76) * 1073741824)) + " Bytes";
 
Share this answer
 
Comments
[no name] 5-Aug-13 8:58am    
how you have calculate it to get (4,047,660,432 bytes) ??
check google calculation it give else number :

https://www.google.com.lb/search?q=bgb+to+byte&oq=bgb+to+byte&aqs=chrome.0.69i57j0l3.10547j0&sourceid=chrome&ie=UTF-8#sclient=psy-ab&q=gb+to+byte&oq=gb+to+byte&gs_l=serp.3..0i7i10i30j0i20j0l2.6028.6117.0.7063.2.2.0.0.0.1.430.606.0j1j4-1.2.0....0...1c.1.23.psy-ab..1.1.427.AUfD9-SNfDM&pbx=1&fp=a696db02711d2fcf&biw=1366&bih=643&bav=on.2,or.r_qf.&cad=b&bvm=pv.xjs.s.en_US.seW1cfrvSKg.O

or

http://www.convertunits.com/from/GB/to/byte

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900