Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Infinity result

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-05-2009, 11:24 AM
jgm jgm is offline
Junior Member
 
Join Date: May 2008
Location: Lisbon
Posts: 22
Default Infinity result

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 Images
File Type: jpg 2.jpg (9.7 KB, 15 views)
File Type: jpg 1.jpg (9.2 KB, 12 views)
Reply With Quote
  #2 (permalink)  
Old 02-05-2009, 11:59 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Wi = 0 ?
Reply With Quote
  #3 (permalink)  
Old 02-05-2009, 12:41 PM
jgm jgm is offline
Junior Member
 
Join Date: May 2008
Location: Lisbon
Posts: 22
Default

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
Reply With Quote
  #4 (permalink)  
Old 02-05-2009, 12:45 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

If you posted some source code that displayed the problem we might find out!
Reply With Quote
  #5 (permalink)  
Old 02-05-2009, 01:52 PM
jgm jgm is offline
Junior Member
 
Join Date: May 2008
Location: Lisbon
Posts: 22
Default

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
Reply With Quote
  #6 (permalink)  
Old 02-05-2009, 02:12 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

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

Replace:
Code:
<font size="2"><font face="Courier New"><font size="2"><font face="Courier New">Scps = - Mcp / Ws</font></font>
<font size=
"2"><font face="Courier New">Scpi = + Mcp / Wi</font></font>
 
<font size=
"2"><font face="Courier New">Ssbs = - Msb / Ws</font></font>
<font size=
"2"><font face="Courier New">Ssbi = + Msb / Wi</font></font>
</font></font>
by

Code:
<font size="2"><font face="Courier New"><font size="2"><font face="Courier New">Scps = - Mcp / Ws</font></font>
<font size=
"2"><font face="Courier New">Scpi = Mcp / Wi</font></font>
 
<font size=
"2"><font face="Courier New">Ssbs = - Msb / Ws</font></font>
<font size=
"2"><font face="Courier New">Ssbi = Msb / Wi</font></font>
</font></font>
Best regards.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #7 (permalink)  
Old 02-05-2009, 02:37 PM
jgm jgm is offline
Junior Member
 
Join Date: May 2008
Location: Lisbon
Posts: 22
Default

Thank you for solving the mystery.

Best regards,

jgm
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wait for an event result within a sub Cableguy Questions (Windows Mobile) 3 01-25-2009 07:05 PM
Inconsistant compiler result glook Questions (Windows Mobile) 3 03-04-2008 06:44 PM


All times are GMT. The time now is 03:47 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0