![]() |
|
IMP - Not this old chestnut again - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2) +--- Thread: IMP - Not this old chestnut again (/showthread.php?tid=3127) Pages:
1
2
|
IMP - Not this old chestnut again - Dimster - 10-16-2024 I've been having so/so results using the IMP logical operator, mostly falling back on all the other operators or Select Case. Recently, because we now have Co-Pilot and Gemini I have revisited my IMP failures. Gemini is now telling me that QB64PE either has a bug or mishandles string values with the IMP logical operator. It starts back with the following simple code: Code: (Select All) Input "Which color do you prefer? Pink or Blue: ",C$Gemini feels this code is correct and should generate the correct response however the IDE highlights an error on the ' If C$ = "Pink" IMP "Girl" then' line. The error message reads that I cannot convert a number to a string. It seems the left side of the IMP operator is fine ( ie If C$ = "Pink" but the right side of IMP is looking for a number and does not recognize a string value. Tried changing the right side to a Boolean comparison ( ie If C$ = "Pink" IMP NOT("Girl" = "") but still can't come up with the correct answer. Trying to get Gemini to keep correcting the code to make IMP work with this set of conditions it became frustrated with me (of course that's how I took it and not real frustration on its part) and gave a very simple Select Case routine to deal with this simple color question. While Gemini was thinking the above was an issue for IMP dealing with string values it told me QB64PE could have a bug in its application of IMP after the following code using IMP was tested : Code: (Select All) Input "Enter your age: ", ageThe above code was Gemini's answer to a previous attempt on the use of IMP and touts that this code gives the correct answer. Gemini's actual defense of this code reads " The issue was that the isADULT variable was being assigned the result of the comparison age >= 18. This means that isADULT would be True only if the age is greater than or equal to 18. However, the IMP operator was being used incorrectly. The IMP operator should be used to check if the condition "age is greater than or equal to 18 implies adult" is True. But Gemini's "corrected code" still does NOT give the correct answer. Moral of the story : To And, Or or XOR is devine to IMP is just gossip. RE: IMP - Not this old chestnut again - bplus - 10-16-2024 This accomplishes the first code directly: Code: (Select All) Input "Which color do you prefer? Pink or Blue: ", C$Why mess with something simple and straight forward? The thing about IMP as bit operator (not particularly Logical in human sense) which does need numbers to operate on is that when the premise A is false IMP will return True, does not matter what 2nd premise B is true or false. This completes the Truth Table for doing bit operations and the sole reason why IMP exists, so you can have a special set of results for each combination TF premise A and TF premise B. If A is false it returns True regardless what B is. RE: IMP - Not this old chestnut again - SMcNeill - 10-16-2024 A IMP B (NOT A) OR B The two statements above are basically perfect replacements for each other. So what you're saying with "Pink" IMP "Girl" is basically: IF (NOT "Pink") OR "Girl" THEN Now, since those are bitwise comparisons, can you see why that doesn't work at all? RE: IMP - Not this old chestnut again - Dimster - 10-16-2024 I totally agree. There are oh so many ways to code to avoid anything to do with IMP. However, my fascination with it is that it appears to be the only Logical Operator that is not logical at all. A computer only understands 1 and 0 so all your coding not only needs to have a logical flow but comes down to just 2 things - 1 or 0. The case of IMP has more of a hint of human logic than computer logic. We humans IMPLY tons of things, like Captain Kirk v's Spock. I'm not sure if our society still finds it appropriate to imply Blue is for Boys but when we look at some one in blue at the very far end of the Mall hallway, we could be thinking "that guy up there.." In terms of AI generative making it to the next level of AI general, I'm thinking IMP may take on new importance role in prediction. RE: IMP - Not this old chestnut again - SMcNeill - 10-16-2024 IMP is just shorthand for NOT A OR B. a IMP b.... NOT a OR b That's all it is. All it does. Nothing fancy to see here. Just 2 letters less typing. The compiler probably translates both into the exact same assembly, in the end. RE: IMP - Not this old chestnut again - Kernelpanic - 10-16-2024 Interesting thing. But IMP is not completely useless. Example of how logical operators can be used to decide on the creditworthiness of a loan applicant. Code: (Select All)
PS: For better understanding
RE: IMP - Not this old chestnut again - Pete - 10-16-2024 Code: (Select All)
Pete - The Bud Light's on but nobody's buying it. RE: IMP - Not this old chestnut again - doppler - 10-18-2024 (10-16-2024, 10:25 PM)Pete Wrote:What Sacrilege Pete. How dare you define what a girl is. What gall you have for doing it. There are millions of people (the unwashed part) when ask "What is a girl ?" Won't or can't do it. /sarcasm off RE: IMP - Not this old chestnut again - SMcNeill - 10-18-2024 My granny -- born in 1880 and who only had a third grade education -- could even tell you rhe definition for a boy/girl. According to granny: "A boy has three knees. A right knee. A left knee. And a WEENY! A girl don't." Swore by that so much so, that even after WWII, when my uncle (her brother) came home with a leg missing, she told him, "Guess you gots to start wearing a dress now, seeing as how you ain't a REAL man, no more!" RE: IMP - Not this old chestnut again - TempodiBasic - 10-19-2024 Dear Dimster why do you like waste your time with Gemini IA and with IMP logic operator? if you run in QB64IDE your second code example you'll get the wrong result until you would type () around age>=18 and you set True = -1. try to run this code in QB64IDE Code: (Select All)
here to learn IMP logic operator how it works... IMP logic operator (english) but Gemini IA is a great donkey if it wants to get IMP logic result passing to IMP a not boolean arguments. synthax Boolean1 IMP Boolean2 as KernelPanic has showed into his code Code: (Select All)
Quote:Moral of the story : To And, Or or XOR is devine to IMP is just gossipyeah and this is another GOSSIP GOSSIP (Maneskin) Take care of your time friend! |