Omnimaga
Calculator Community => TI Calculators => Axe => Topic started 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?
-
The equals operator in Axe is a 16-bit comparison. Perhaps A is being set improperly?
-
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...
-
Can you post an example? Yeah that might be the r thing indeed.
-
I think he meant an 8-bit comparison, not a 16 bit comparison...
-
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.
-
Basically he wants to only compare the LSB, as far as I can tell.
-
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.
-
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
-
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)
-
So, it turns out I forgot to do the {P}^r thingy. It works now! :D Thanks guys!
-
Hmm you posted 3 times in a row ???
-
I actually don't even get what "to return false when A=256 for A=0" means O.o explain please?
-
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.
-
ah. thanks for explaining.
(so if I get it right he wants to check if the hex number is 00xx)?
-
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.