CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2005
    Location
    Roma - Italy
    Posts
    46

    Result of division

    Code:
    Dim q1 As Double
    Dim q2 As Double
    Dim res As Double
    
    q1 = 17.59
    q2 = 1300
    
    res = q1 / q2
    
    MsgBox res
    Result = 1,35307692307692E-02

    With Windows calculator

    17.59 / 1300 = 0.0135307692 ......

    Someone know why?
    Sorry for my english language!
    -------------------------------
    mrhyde.altervista.org
    Free resource
    ------------------------------

  2. #2
    Join Date
    Jun 2005
    Location
    Roma - Italy
    Posts
    46

    Re: Result of division

    I add another info.
    The strange thing is that if we build a dll ActiveX that receive q1 and q2 value and make the result, if the application caller is a VB application the result is 1,25307.....

    Instead, if tha application caller is VC++, the result is right and it is 0.01353....

    For me it's incredible...
    Someone know why?!?!?
    Sorry for my english language!
    -------------------------------
    mrhyde.altervista.org
    Free resource
    ------------------------------

  3. #3
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    651

    Re: Result of division

    Quote Originally Posted by E.Hyde
    Result = 1,35307692307692E-02

    With Windows calculator

    17.59 / 1300 = 0.0135307692 ......

    Someone know why?

    1.35307692307692E-02 is the same as 0.0135307692307692

    The E-02 is scientific notation. The number after the E tells how many places to move the decimal and which direction to move it in. In this case, the negative means to move it left and the 2 means to move it 2 places (which gives you 0.0135307692307692).
    I'd rather be wakeboarding...

  4. #4
    Join Date
    Nov 2004
    Posts
    105

    Re: Result of division

    Both are same sir

    use this
    Dim q1 As Double
    Dim q2 As Double
    Dim res As Double
    Dim resf As Double

    q1 = 17.59
    q2 = 1300

    res = q1 / q2
    resf = Format(res, "##,##0.000000000")
    MsgBox resf

    you have to change the format

  5. #5
    Join Date
    Jun 2005
    Location
    Roma - Italy
    Posts
    46

    Red face Re: Result of division

    I'm ashamed of this.

    Thanks a lot, sorry, but i'm a champion in math!!
    Sorry for my english language!
    -------------------------------
    mrhyde.altervista.org
    Free resource
    ------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured