Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: geekygenius on May 03, 2012, 10:31:43 pm

Title: 256=0?
Post by: geekygenius on May 03, 2012, 10:31:43 pm
So, I was wondering if there was a way to get a 16-bit variable A to return false when A=256 for A=0. Essentially, how do I force a 16 bit comparison?
Title: Re: 256=0?
Post by: Runer112 on May 03, 2012, 10:34:44 pm
The equals operator in Axe is a 16-bit comparison. Perhaps A is being set improperly?
Title: Re: 256=0?
Post by: geekygenius on May 03, 2012, 10:46:18 pm
A is being set through a pointer, and it can be set over 256 and get something over 256. Maybe I forgot the little r thingy that goes after the variable to make it 16 bit...
Title: Re: 256=0?
Post by: Juju on May 03, 2012, 10:48:10 pm
Can you post an example? Yeah that might be the r thing indeed.
Title: Re: 256=0?
Post by: ZippyDee on May 03, 2012, 11:50:44 pm
I think he meant an 8-bit comparison, not a 16 bit comparison...
Title: Re: 256=0?
Post by: Deep Toaster on May 04, 2012, 12:05:14 am
I think he meant an 8-bit comparison, not a 16 bit comparison...
He said he wanted it "to return false when A=256 for A=0," which would be sixteen bits (which it already is).

Since you're setting it as a pointer, here's something to keep in mind, if you're not aware of it already: Numbers are stored in little-endian format, which means the first byte is the low byte (the the number modulo 256), and the byte after it is the high byte (the number divided by 256).

So if you're doing something like 1→{°A+1} when A was originally zero, A would now equal 256.

Not sure if that's your problem, but I hope that helps.
Title: Re: 256=0?
Post by: ZippyDee on May 04, 2012, 01:15:07 am
Basically he wants to only compare the LSB, as far as I can tell.
Title: Re: 256=0?
Post by: geekygenius on May 04, 2012, 01:33:14 am
I think he meant an 8-bit comparison, not a 16 bit comparison...
He said he wanted it "to return false when A=256 for A=0," which would be sixteen bits (which it already is).

Since you're setting it as a pointer, here's something to keep in mind, if you're not aware of it already: Numbers are stored in little-endian format, which means the first byte is the low byte (the the number modulo 256), and the byte after it is the high byte (the number divided by 256).

So if you're doing something like 1→{°A+1} when A was originally zero, A would now equal 256.

Not sure if that's your problem, but I hope that helps.
D: I don't get why we can't just have the bytes go in a logical order. Thanks though, I'll look at my program with this knowledge. I can just bit-wise and both bits together if I need to. I will also post my final code when I get done, for anyone else with the same question.
Title: Re: 256=0?
Post by: Netham45 on May 04, 2012, 02:08:20 am
It's up to the CPU, the z80 only handles little-endian. Both storage models (little-endian, big-endian) make sense at different parts of the processes of reading/writing/storing
Title: Re: 256=0?
Post by: Hayleia on May 04, 2012, 11:47:25 am
D: I don't get why we can't just have the bytes go in a logical order.
Because if you have a pointer to a 16-bits value that is under 255, you can use the same pointer and get the same value with only 8-bits (dunno if I explained well :P)
Title: Re: 256=0?
Post by: geekygenius on May 04, 2012, 06:32:07 pm
So, it turns out I forgot to do the {P}^r thingy. It works now! :D Thanks guys!
Title: Re: 256=0?
Post by: DJ Omnimaga on May 04, 2012, 06:34:56 pm
Hmm you posted 3 times in a row ???
Title: Re: 256=0?
Post by: aeTIos on May 08, 2012, 06:05:43 am
I actually don't even get what "to return false when A=256 for A=0" means O.o explain please?
Title: Re: 256=0?
Post by: Netham45 on May 08, 2012, 06:06:55 am
I actually don't even get what "to return false when A=256 for A=0" means O.o explain please?

He wants to check if the least significant byte is all zero.
Title: Re: 256=0?
Post by: aeTIos on May 08, 2012, 06:08:18 am
ah. thanks for explaining.
(so if I get it right he wants to check if the hex number is 00xx)?
Title: Re: 256=0?
Post by: Deep Toaster on May 08, 2012, 11:15:19 pm
Actually what he wanted was for the statement A=0 to return 0 (false) when A is 256, because he thought it would return 1 (true). It turned out to be a different problem, though.