Post Reply 
SIGN Function
01-04-2017, 04:19 PM (This post was last modified: 01-04-2017 04:21 PM by StephenG1CMZ.)
Post: #10
RE: SIGN Function
(01-04-2017 12:19 PM)ggauny@live.fr Wrote:  It is always the same result : Date OK

if I write 23 2 1935
or 0 2 1935
or 23 0 1935
or 23 2 0

I obtain "Date OK" !!!

I was wanted a sort cut, but ...

To explain why it is not working: your program logic is not correct.
These examples all yield the same answer:

Sign of 23 2 95 is 1 or 1 or 1 which is 1==0
Sign of. 0 2 95 is 0 or 1 or 1 which is 1
Sign of 23 0 95 is 1 or 0 or 1 which is 1
Sign of 23 2 0 is 1 or 1 or 0 which is 1

Sign of 0 0 0 is 0 or 0 or 0 which is 0==0 (the only time your date is not ok)

The sign generates 0 if the input is 0
The Or generates 0 only if every input is 0, otherwise its 1.

To check if J A M are all nonzero you could use
If J AND A AND M // Prime treats 0 as false
THEN PRINT("Date maybe ok"); //All three nonzero
// dont forget many other invalid dates exist, eg 33 3 95
ELSE PRINT("At least one 0");
END;//IF

Hope that makes it clearer

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
SIGN Function - ggauny@live.fr - 01-04-2017, 08:19 AM
RE: SIGN Function - Carlos295pz - 01-04-2017, 10:58 AM
RE: SIGN Function - DrD - 01-04-2017, 11:04 AM
RE: SIGN Function - ggauny@live.fr - 01-04-2017, 11:38 AM
RE: SIGN Function - DrD - 01-04-2017, 11:55 AM
RE: SIGN Function - ggauny@live.fr - 01-04-2017, 12:19 PM
RE: SIGN Function - StephenG1CMZ - 01-04-2017 04:19 PM
RE: SIGN Function - Didier Lachieze - 01-04-2017, 03:12 PM
RE: SIGN Function - ggauny@live.fr - 01-04-2017, 03:34 PM
RE: SIGN Function - Didier Lachieze - 01-04-2017, 04:10 PM
RE: SIGN Function - DrD - 01-05-2017, 12:38 PM
RE: SIGN Function - DrD - 01-09-2017, 10:33 AM



User(s) browsing this thread: 1 Guest(s)