Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Camdenmil on January 15, 2011, 07:25:04 pm

Title: Changing bits
Post by: Camdenmil on January 15, 2011, 07:25:04 pm
I'm probably missing something, but is there a way to get/set the value of a single bit in axe?
Title: Re: Changing bits
Post by: squidgetx on January 15, 2011, 07:27:47 pm
Documentation has this for reading bits:
Code: [Select]
EXPeBIT# where e is euler's e. Returns BIT# of EXP, where the high bit is bit0 and the low bit is bit 7. Example, 255e0 would return 1.

Writing to bits, you basically have to "or" the bit over; so
Code: [Select]
e^(bit#) or EXP -> EXP As for resetting bits, I forget...

edit: here's a more optimizedish version by runer112; http://ourl.ca/7815/138430
Title: Re: Changing bits
Post by: nemo on January 15, 2011, 10:04:21 pm
or will set a bit
and will reset a bit
xor will toggle a bit
Code: [Select]
e^(#) [or/and/xor] EXP->EXP
where # is the bit to set 0-7 starting from the right hand side.
Title: Re: Changing bits
Post by: calc84maniac on January 15, 2011, 10:15:24 pm
Actually, for and you need to use not(e^(#)) and EXP->EXP
Title: Re: Changing bits
Post by: Binder News on January 15, 2011, 10:37:55 pm
How 'bout an Axiom, anyone?
Title: Re: Changing bits
Post by: AngelFish on January 15, 2011, 10:38:48 pm
Perhaps I'm behind in my Axe, but I wasn't aware that the Not( function was implemented in Axe.
Title: Re: Changing bits
Post by: calc84maniac on January 15, 2011, 10:44:21 pm
Perhaps I'm behind in my Axe, but I wasn't aware that the Not( function was implemented in Axe.
It was added in Axe 0.4.7: "Bitwise complement command for 8 and 16 bit numbers"
Title: Re: Changing bits
Post by: AngelFish on January 15, 2011, 10:49:12 pm
I've been wanting that function for quite some time. Thanks for pointing it out  :)