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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top