| Home CBM ASCII-X BASIC Disk Commands Enter RUN mode Program Format Secret Variables Variable Format Expressions Keywords (divide) (equal) (less) (minus) (more) (multiply) (plus) (power) Abs And Append Asc Atn Auto Backup Bank Begin Bend Bload Boot Box Bsave Bump Catalog Char Chr Circle Close Clr Cmd Collect Collision Color Concat Cont Copy Cos Data Dclear Dclose Dec Def Delete Dim Directory Dispose Dload Do Dopen Draw Ds Ds string Dsave Dverify El Else End Envelope Er Err Exit Exp Fast Fetch Filter Fn For Fre Get Get num Getkey Go Gosub Goto Graphic Gshape Header Help Hex If Input Input num Instr Int Joy Key Left Len Let List Load Locate Log Loop Mid Monitor Movspr New Next Not Off On Open Or Paint Peek Pen Pi Play Pointer Poke Pos Pot Print num Pudef Quit Rclr Rdot Read Record Rem Rename Renumber Restore Resume Return Rgr Right Rlum Rnd Rreg Rspcolor Rsppos Rsprite Run Rwindow Save Scale Scnclr Scratch Sgn Sin Sleep Slow Sound Spc Sprcolor Sprdef Sprite Sprsav Sqr Sshape St Stash Step Stop Str Swap Sys Tab Tan Tempo Then Ti Ti string To Trap Troff Tron Until Using Usr Val Verify Vol Wait While Width Window Xor Syntax Tokens C128 D64plus Disk Escape Codes Hardware PCxface PETSCII Pet2asc Futurama IBM PC-AT Contact Games Glossary Hall of fame Hall of shame Miscellaneous Privacy policy Programming Twisty puzzles |
subject < comparator ~ or ~ subject < = comparator ~ or ~ subject = < comparator ~ or ~ subject < > comparator ~ or ~ subject > < comparator
Evaluate a comparative relation.
The less operator returns a boolean result; it may be used in one of three ways:
It is interesting that BASIC allows some operators to be combined to form new operators (as shown here), but unfortunately it is not very general. For example you can't combine the not and less operators to form a NOT < operator -- you have to do it manually! Manual operations are error prone because some people don't know that NOT < is equivallant to greater-than-or-equal-to ( >= ) and is different from strictly more ( > ). Heck, even people who do know better (like me) will occassionally make mistakes. Similarly, combining NOT with AND to form NAND is forbidden as well. Another interesting thing is spaces may appear between the operators when combining them and the order of combination is not important; in programming of other languages (including some other BASICs), this "easy syntax" will fail. It should also be noted that the first form (strictly less than) is generally considered safe with floating-point numbers, while the others are not due the involvement of equality. Specifically, the nature of floating-pointing numbers means there will often be subtle rounding errors that will make two numbers that should be the same (may even print as the same value) will not be exactly the same leading to an invalid result. This is true with any finite-representation of real numbers (floating-point in this case) and is not a blemish on CBM. On the contrary, CBM 8-bit computers use a 32-bit mantissa which has more precision than most 8-bit BASICs or even the "float" type in modern languages such as Visual BASIC and C which use a 24-bit mantissa. Relational operators (like less) are frequently used with IF, DO, and LOOP.
© H2Obsession, 2014, 2019 Thanks to Tiaan Geldenhuys for correction of token value!! |