Jump to content
IGNORED

Boolean functions in TI BASIC


ralphb

Recommended Posts

I'm totally flashed by the fact that the following TI BASIC program runs fine and outputs 1 and 0.

10 A=1
20 B=NOT(A)
30 PRINT A;B

Same for AND and OR (with two arguments).  Those functions also work for IF.

 

Looking at the TI BASIC Reference manual, I find no mention of these boolean functions.  Also, the reference suggests using * for AND and + for OR, like I did back in the day.

 

Do I suffer from amnesia, or is this also news to some people?

 

EDIT: Tried on real iron, without peripherals.

Edited by ralphb
  • Like 1
Link to comment
Share on other sites

I can't really follow here...

 

Are you talking about TI Console BASIC or Extended BASIC? The tokens have been introduced only in XB according to Ninerpedia:

image.thumb.png.23e5c0e61a3f7d4f799264fe60d1202e.png

 

And "A=NOT(0)" is not inverting the logical value of B, but declares an array with default dimension 10 and accesses the 0 index value, which is defaultet to 0.

 

I did use logical "boolean" statements a lot in TI BASIC, but in a way "x=x+(k=83)-(k=69)", as true was computed to -1, which is actually funny, as -1 is signed integer >FFFF, all bits set to 1 ... but the TI BASIC does not have 16bit Integers...

 

Cheers,

Steve

 

  • Like 6
  • Thanks 1
Link to comment
Share on other sites

9 minutes ago, SteveB said:

And "A=NOT(0)" is not inverting the logical value of B, but declares an array with default dimension 10 and accesses the 0 index value, which is defaultet to 0.

Oh, that makes sense!  My bad, I didn't think of that, and chose my examples very poorly. ?

 

But I also didn't know you can create arrays en passant without a DIM.  Anyway, sanity restored.

Link to comment
Share on other sites

4 hours ago, ralphb said:

I'm totally flashed by the fact that the following TI BASIC program runs fine and outputs 1 and 0.


10 A=1
20 B=NOT(A)
30 PRINT A;B

Same for AND and OR (with two arguments).  Those functions also work for IF.

 

Looking at the TI BASIC Reference manual, I find no mention of these boolean functions.  Also, the reference suggests using * for AND and + for OR, like I did back in the day.

 

Do I suffer from amnesia, or is this also news to some people?

 

EDIT: Tried on real iron, without peripherals.

GPL programmer here and have my own modified XB too.

Your program A is a variable and so is B but as you used NOT as an array NOT(array number) it thinks NOT is also a VARIABLE too.

(NOT is not a command subprogram in TI Basic, it is in XB)

Thus NOT(A) variable is 0 as it has no value assigned to it yet in TI Basic.

That is why in TI Basic PRINT A;B is A=1 and B=0

 

But in XB you get PRINT A=1 and B=-2 as NOT is a command subprogram in XB.

 

Link to comment
Share on other sites

Semantic, but AND, OR, and NOT are operators, and not functions.  If there is a dialect of BASIC which implements them as a function, I imagine they had to be shoe-horned in as such.

 

@RXB hey, is that maybe why creating a MOD operator is not going well in RXB?  Is there a difference between look-ups for functions and operators?

Link to comment
Share on other sites

3 minutes ago, OLD CS1 said:

Semantic, but AND, OR, and NOT are operators, and not functions.  If there is a dialect of BASIC which implements them as a function, I imagine they had to be shoe-horned in as such.

 

@RXB hey, is that maybe why creating a MOD operator is not going well in RXB?  Is there a difference between look-ups for functions and operators?

CALL MOD(number,divisor,quotiant,remainder) works as intended in RXB 2022 and adding a token to XB is a real pain but Lee Stewart and I are working on it.

And yes a CALL is much more easy to implement as it uses the same look up as DSR for devices in GPL.

 

And a TOKEN like NOT, AND OR on other hand are a pain as you need a to add it to token table in GPL and ROMs.

Then the fun part is to add it to the NUD TABLE in Assembly and GPL  so it can PRE SCAN for it before the program is run.

This requires an entire rewrite of the ROMs as not that much hassle to add to GPL.

There are 3 different spots in XB ROMs that need to be absolute addressed in order to add tokens, oddly TI did not allow for adding them unless a total REWRITE.

That would be a major reason for only 100 and 110 version of XB ever released. XB3 tried but he sacrificed more than it was worth.

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

On 1/2/2022 at 4:07 PM, SteveB said:

I did use logical "boolean" statements a lot in TI BASIC, but in a way "x=x+(k=83)-(k=69)", as true was computed to -1, which is actually funny, as -1 is signed integer >FFFF, all bits set to 1 ... but the TI BASIC does not have 16bit Integers...

No, but you can still store integer values in BASIC's floating point variables. And if you do use boolean arithmetic on these values (with operators like AND, OR and NOT in Extended BASIC), then it will operate on the 16-bit integer parts of the value in the variable.

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...