Divide by zero problem when porting FoxPro 2.6 (Win) to Visual FoxPro 
Author Message
 Divide by zero problem when porting FoxPro 2.6 (Win) to Visual FoxPro

Hi,

I'm attempting to convert a rather large project from 2.6 to Visual FoxPro,
and I've come across a very strange difference in the way they each seem to
handle division by zero.
By tracing the 2.6 version I've determined that dividing anything by zero
returns a result of .f., which is treated as if it were 0 (which makes
sense). However, in the partially converted version running under Visual
FoxPro the result of the division is displayed as ********** in the
de{*filter*}, which I assume means "undetermined" or "error" or some such thing.
This, however, does not seem to be treated as 0 by the if statement a little
later in the code that traps non-zero values for variables, and causes the
whole thing to come crashing down a few seconds later... This is a bit of a
problem, as the code seems to rely on the old behaviour to function
correctly, and it's just too large to search through and rewrite occurrence
by occurrence.

I'm very new to FoxPro, let alone the Visual version, so I'm sorry if I'm
missing anything truly obvious here. I've thought about trapping the problem
with ON ERROR, but dividing by zero doesn't seem to cause any kind of
detectable error, and I'm now pretty much stumped!

Thanks for your time,
Andrew



Fri, 24 May 2002 03:00:00 GMT  
 Divide by zero problem when porting FoxPro 2.6 (Win) to Visual FoxPro
Sorry, I ought to mention that I'm using Visual FoxPro 5.0

Andrew



Fri, 24 May 2002 03:00:00 GMT  
 Divide by zero problem when porting FoxPro 2.6 (Win) to Visual FoxPro
Hi Andrew,

Unfortunately, I see no way out of your dilemma. Everything you say is true
and you must find all of the possible trouble spots in your old code. You
should be able to trap the error by using the ASSERT command in the relevant
locations. The syntax is like this:

ASSERT n1>0    MESSAGE 'Divisor must be greater than 0'

where n1 is your variable name.

To make this code work, somehwere in the beginning of your program or in
your environment, issue the command:

SET ASSERTS ON

Best regards,
Tom


Quote:
> Hi,

> I'm attempting to convert a rather large project from 2.6 to Visual
FoxPro,
> and I've come across a very strange difference in the way they each seem
to
> handle division by zero.
> By tracing the 2.6 version I've determined that dividing anything by zero
> returns a result of .f., which is treated as if it were 0 (which makes
> sense). However, in the partially converted version running under Visual
> FoxPro the result of the division is displayed as ********** in the
> de{*filter*}, which I assume means "undetermined" or "error" or some such
thing.
> This, however, does not seem to be treated as 0 by the if statement a
little
> later in the code that traps non-zero values for variables, and causes the
> whole thing to come crashing down a few seconds later... This is a bit of
a
> problem, as the code seems to rely on the old behaviour to function
> correctly, and it's just too large to search through and rewrite
occurrence
> by occurrence.

> I'm very new to FoxPro, let alone the Visual version, so I'm sorry if I'm
> missing anything truly obvious here. I've thought about trapping the
problem
> with ON ERROR, but dividing by zero doesn't seem to cause any kind of
> detectable error, and I'm now pretty much stumped!

> Thanks for your time,
> Andrew



Fri, 24 May 2002 03:00:00 GMT  
 Divide by zero problem when porting FoxPro 2.6 (Win) to Visual FoxPro
Andrew

Hmm....interesting discovery.

Mathematically, dividing any number by 0 will result infinity which in
foxpro is represent with ********. While zero dividing by any number
results zero.

I'm confuse and unable to reproduce your case (in FPW 2.6) where the result
is .f. and equal to 0.

I try this both in fpw 2.6 and vfp 6.0:

?12345/0

********

a=10200
b=0
?a/b

***********

And I try to save this result into a table it will generate error: Numeric
overflow (data was lost).

farid



Sat, 25 May 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. divide by zero error with Foxpro 2.6 and NT4

2. Divide by zero patch for Foxpro 2.6

3. WTB: Foxbase+, FoxPro 1.0 for Win, FoxPro 2.0 for DOS, FoxPro 2.6 DOS/Win

4. FOXPRO 2.6 (MAC) to Win NT Visual FoxPro vs ACCESS vs ORACLE

5. FoxPro 2.5 Zero Divide Error on 500Mhz Machine

6. Problem with Foxpro 2.6 on Win 95 and Win 3.x

7. 2.6 Divide by Zero Error when loading???

8. Divide by zero error in 2.6

9. Porting from Foxpro MAC to Foxpro Win

10. LCK divide by zero problem HELP!!!

11. Foxpro 2.6 divide error

12. Problem with LISTS in Foxpro Win 2.6

 

 
Powered by phpBB® Forum Software