Author Topic: 256=0?  (Read 8786 times)

0 Members and 2 Guests are viewing this topic.

Offline geekygenius

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 17
  • Rating: +4/-0
    • View Profile
256=0?
« 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?

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: 256=0?
« Reply #1 on: May 03, 2012, 10:34:44 pm »
The equals operator in Axe is a 16-bit comparison. Perhaps A is being set improperly?

Offline geekygenius

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 17
  • Rating: +4/-0
    • View Profile
Re: 256=0?
« Reply #2 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...

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: 256=0?
« Reply #3 on: May 03, 2012, 10:48:10 pm »
Can you post an example? Yeah that might be the r thing indeed.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline ZippyDee

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +83/-8
  • Why not zoidberg?
    • View Profile
Re: 256=0?
« Reply #4 on: May 03, 2012, 11:50:44 pm »
I think he meant an 8-bit comparison, not a 16 bit comparison...
There's something about Tuesday...


Pushpins 'n' stuff...


Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: 256=0?
« Reply #5 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.
« Last Edit: May 04, 2012, 12:05:32 am by Deep Thought »




Offline ZippyDee

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +83/-8
  • Why not zoidberg?
    • View Profile
Re: 256=0?
« Reply #6 on: May 04, 2012, 01:15:07 am »
Basically he wants to only compare the LSB, as far as I can tell.
There's something about Tuesday...


Pushpins 'n' stuff...


Offline geekygenius

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 17
  • Rating: +4/-0
    • View Profile
Re: 256=0?
« Reply #7 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.

Offline Netham45

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2103
  • Rating: +213/-4
  • *explodes*
    • View Profile
Re: 256=0?
« Reply #8 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
Omnimaga Admin

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: 256=0?
« Reply #9 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)
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline geekygenius

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 17
  • Rating: +4/-0
    • View Profile
Re: 256=0?
« Reply #10 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!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: 256=0?
« Reply #11 on: May 04, 2012, 06:34:56 pm »
Hmm you posted 3 times in a row ???

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: 256=0?
« Reply #12 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?
I'm not a nerd but I pretend:

Offline Netham45

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2103
  • Rating: +213/-4
  • *explodes*
    • View Profile
Re: 256=0?
« Reply #13 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.
Omnimaga Admin

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: 256=0?
« Reply #14 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)?
I'm not a nerd but I pretend: