Infinity result

Discussion in 'Questions (Windows Mobile)' started by jgm, Feb 5, 2009.

  1. jgm

    jgm Member Licensed User

    Hi,

    I'm doing some simple calculations and got unexpectedly an "infinity" result.

    I've got some input fields and some output fields in a few forms.
    The calculation that is not working is a simple division:
    Scpi = Mcp / Ws

    I have a button that I click in order to get calculations done.
    When I press that button once, Scpi gets the correct result.
    But if I press that button again, Scpi gets the value "infinity"; the variables Mcp and Ws have the same value (Mcp=20; Ws=0.05; I verified that by debugging).
    I attached two pictures showing Scpi result after the first run and after the second run.
    I've checked every line of the program and found no reason for getting the infinity result since Mcp and Ws are not changed.
    Any idea of what could cause that strange behavior?

    JGM
     

    Attached Files:

    • 2.jpg
      2.jpg
      File size:
      9.7 KB
      Views:
      39
    • 1.jpg
      1.jpg
      File size:
      9.2 KB
      Views:
      36
  2. agraham

    agraham Expert Licensed User

    Wi = 0 ?
     
  3. jgm

    jgm Member Licensed User

    Wi = 0.05

    At the end of the program I wrote two more lines:
    - one to display in a new text box the operation (division)
    - another to display in another textbox the variable to which the result was assigned

    Tb01.Text = Format(Mcp/Wi, "N1")
    Tb02.Text = Format(Scpi, "N1")

    Tb01 displayed the correct result
    Tb02 displayed "infinity"

    Those odd things happen when running the program (by pressing F5 "RUN") while in the Visual Designer.

    Then I compiled the program and run the compiled version.
    Everything went OK. No problems with infinity in the compiled version.
    What is going wrong?

    jgm
     
  4. agraham

    agraham Expert Licensed User

    If you posted some source code that displayed the problem we might find out!
     
  5. jgm

    jgm Member Licensed User

    I'v attached the source code.
    I'm writing in Portuguese; I believe that does not help much.

    There are a few screens but only form01 and form02 are being used.
    Division is done on line 83 and displayed on line 98.
    Pressing the execute key "Xeq" on form 01, the program shows form 02 with the correct results.
    Going back to form01 (pressing the "<" key) and pressing again "Xeq" form 02 is displayed with "infinity" in some textboxes.
    That doesn't happen in the compiled version.

    jgm
     
  6. klaus

    klaus Expert Licensed User

    In lines 83 and 86 you should remove the + sign !

    Replace:
    Code:
    [SIZE=2][FONT=Courier New][SIZE=2][FONT=Courier New]Scps = - Mcp / Ws[/FONT][/SIZE]
    [SIZE=
    2][FONT=Courier New]Scpi = + Mcp / Wi[/FONT][/SIZE]
     
    [SIZE=
    2][FONT=Courier New]Ssbs = - Msb / Ws[/FONT][/SIZE]
    [SIZE=
    2][FONT=Courier New]Ssbi = + Msb / Wi[/FONT][/SIZE]
    [/
    FONT][/SIZE]
    by

    Code:
    [SIZE=2][FONT=Courier New][SIZE=2][FONT=Courier New]Scps = - Mcp / Ws[/FONT][/SIZE]
    [SIZE=
    2][FONT=Courier New]Scpi = Mcp / Wi[/FONT][/SIZE]
     
    [SIZE=
    2][FONT=Courier New]Ssbs = - Msb / Ws[/FONT][/SIZE]
    [SIZE=
    2][FONT=Courier New]Ssbi = Msb / Wi[/FONT][/SIZE]
    [/
    FONT][/SIZE]
    Best regards.
     
  7. jgm

    jgm Member Licensed User

    Thank you for solving the mystery.

    Best regards,

    jgm
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice