Information générale
Catégorie:
Codage, syntaxe et commandes
>x = 0
>y = 0
>
>z = x/y
>
>z > 0 = .F.
>z < 0 = .T.
>z < -1 = .T.
>z < -9999999 = .T.
>
>It's a numeric field but can't be displayed (maybe its negitive infinity?). From a mathmatical standpoint - you can't divide by zero anyway - its supposed to be impossible. I'm suprised VFP doesn't give an error when you try to do that. Anyway I've always just checked for the possibilty in my code where I need to.
I don't know why VFP doesn't throw divide-by-zero errors. I do know you get the equivalent of Field Overflow and a number that can't be used. I do know that I used to have DIVIDEBY() functions which trapped the denominator and returned 0 for DIVIDEBY(x,0)
My first language was APL where 0/0 was (IIRC - it was a long while ago) defined as 1 where other languages defined it as 0 (rather than error). The arguements about the "correct" return value for 0/0 went something like
0/x is 0 therefore 0/0 is 0 and not an error
x/x is 1 therefore 0/0 is 1 and not an error
x/0 is an error therefore 0/0 is an error
I have no idea which is "correct." I justs live with however the language implements it.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement