QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: CharlieJV on February 03, 2022, 10:57:59 am
-
I can't imagine many folk would bother trying that example, but on the off-chance that a programming newcomer did want to learn about AND ...
A little copy/paste typo:
DO
INPUT "Enter Integer value from -32768 to 32767 (Enter quits): ", INTvalue&
IF INTvalue& < -32768 OR INTvalue& > 32767 OR INTval& = 0 THEN EXIT DO
FOR exponent = 15 TO 0 STEP -1
IF (INTvalue& AND 2 ^ exponent) THEN PRINT "1"; ELSE PRINT "0";
NEXT
PRINT " "
LOOP UNTIL INTvalue& = 0 'zero entry quits
-
Looks like you got your wiki account set up. Welcome aboard!
-
I can't imagine many folk would bother trying that example, but on the off-chance that a programming newcomer did want to learn about AND ...
A little copy/paste typo:
DO
INPUT "Enter Integer value from -32768 to 32767 (Enter quits): ", INTvalue&
IF INTvalue& < -32768 OR INTvalue& > 32767 OR INTval& = 0 THEN EXIT DO
FOR exponent = 15 TO 0 STEP -1
IF (INTvalue& AND 2 ^ exponent) THEN PRINT "1"; ELSE PRINT "0";
NEXT
PRINT " "
LOOP UNTIL INTvalue& = 0 'zero entry quits
Fixed:
Input "Enter Integer value from -32768 to 32767 (Enter quits): ", INTvalue&
-
Fixed:
You beat me to it. Next one is on me!
-
Ha! After I posted it was clear to me, you knew the problem (color coded the err) and you were making another point. :-))