Math ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Cantley

    #1

    Math ?

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

    result shows 3.0
    should be: 3.58...

    jc


  • John Cantley

    #2
    Re: Math ?

    BTW, This is the result that shows in the dbl var.

    jc


    Comment

    • Leo Lin

      #3
      Re: Math ?

      I think you should change it to
      double dbFree = ((double)lFreeB ytes / 1073741824D);

      "John Cantley" <jcstrider@hotm ail.com> wrote in message
      news:O#JPANGfDH A.4024@TK2MSFTN GP11.phx.gbl...[color=blue]
      > What am I doing wrong here?
      > lFreeBytes = 3849510912
      > double dbFree = (lFreeBytes / 1073741824);
      > Console.Write(d bFree.ToString( ));
      >
      > result shows 3.0
      > should be: 3.58...
      >
      > jc
      >
      >[/color]


      Comment

      • Nicole Calinoiu

        #4
        Re: Math ?

        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)lFreeB ytes) / 1073741824

        or

        dbFree = lFreeBytes / 1073741824d

        HTH,
        Nicole

        "John Cantley" <jcstrider@hotm ail.com> wrote in message
        news:O%23JPANGf DHA.4024@TK2MSF TNGP11.phx.gbl. ..[color=blue]
        > What am I doing wrong here?
        > lFreeBytes = 3849510912
        > double dbFree = (lFreeBytes / 1073741824);
        > Console.Write(d bFree.ToString( ));
        >
        > result shows 3.0
        > should be: 3.58...
        >
        > jc
        >
        >[/color]


        Comment

        • Marco Rego

          #5
          Math ?

          Hmm, try:

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

          Rgds.

          _____
          Marco

          Comment

          Working...