Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:12 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Logical NOT not working as expected

Author Message
JohnL
Senior Member

Joined: 10/01/2014
Location: Seychelles
Posts: 128
Posted: 01:47pm 25 Dec 2015
Copy link to clipboard 
Print this post

Micromite Plus Firmware 4.07.

NOT 0 returns 1 as expected, single bit.

Logical NOT returns 0 for all other values?

I would expect NOT to work in BASIC with at least a 16 bit integer (0 - &HFFFF)

If NOT only works with a single bit than it is almost useless in BASIC?


 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 03:09pm 25 Dec 2015
Copy link to clipboard 
Print this post

AND, OR and XOR are integer bitwise operators so you can usually use XOR to get a bitwise NOT.

NOT is useful in IF statements.

Jim

VK7JH
MMedit
 
JohnL
Senior Member

Joined: 10/01/2014
Location: Seychelles
Posts: 128
Posted: 04:57pm 25 Dec 2015
Copy link to clipboard 
Print this post

Thanks Jim,

That works.

Just to clarify for anyone else that does not know the details.

If you want to invert (NOT) a 16 bit integer using XOR.

you have to XOR the number with &HFFFF.

Regards
John
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025