Math ?

  • Thread starter Thread starter John Cantley
  • Start date Start date
J

John Cantley

What am I doing wrong here?
lFreeBytes = 3849510912
double dbFree = (lFreeBytes / 1073741824);
Console.Write(dbFree.ToString());

result shows 3.0
should be: 3.58...

jc
 
John,

Since the operands are a long and an int, the result is an int. Try making
at least one of them a double. e.g.:

dbFree = ((double)lFreeBytes) / 1073741824

or

dbFree = lFreeBytes / 1073741824d

HTH,
Nicole
 
Hmm, try:

const double lFreeBytes = 3849510912.0;
double dbFree = (lFreeBytes / 1073741824.0);
Console.Write(dbFree.ToString());

Rgds.

_____
Marco
 
Back
Top