Author Topic: Negative/Opposite Numbers (SOLVED)  (Read 3134 times)

0 Members and 1 Guest are viewing this topic.

Offline Derf321

  • LV3 Member (Next: 100)
  • ***
  • Posts: 59
  • Rating: +0/-0
    • View Profile
Negative/Opposite Numbers (SOLVED)
« on: November 20, 2012, 03:17:31 pm »
Is there a way I can make it so "If EXP1 = true, 1→Z, else, -1→Z"? Or some variation of this? I need a negative number to use in a formula (as in the output eventually will not be negative)
« Last Edit: November 27, 2012, 11:29:51 pm by Derf321 »

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Negative/Opposite Numbers
« Reply #1 on: November 20, 2012, 03:19:03 pm »
Code: [Select]
EXP1=true*2-1→Z

That's not optimized at all, but it's easy enough to see why it works.
« Last Edit: November 20, 2012, 03:19:56 pm by leafy »
In-progress: Graviter (...)

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Negative/Opposite Numbers
« Reply #2 on: November 20, 2012, 03:19:42 pm »
...that's actually pretty optimized actually :P
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

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: Negative/Opposite Numbers
« Reply #3 on: November 20, 2012, 03:20:14 pm »
(2*(EXP1=1)-1)→Z should do the job, if (EXP1=1) returns either 0 or 1 as in TI-BASIC.

EDIT: Ninja'd. But you should understand the point.
« Last Edit: November 20, 2012, 03:21:35 pm by Juju »

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 bored_student

  • LV3 Member (Next: 100)
  • ***
  • Posts: 44
  • Rating: +3/-0
    • View Profile
Re: Negative/Opposite Numbers
« Reply #4 on: November 22, 2012, 03:17:32 am »
couldn't you leave the parentheses
Code: [Select]
1=EXP1*2-1→Z
or if the "true" isn't always 1
Code: [Select]
0<EXP1*2-1→Z
Sorry for my bad English, I'm German.

Offline Derf321

  • LV3 Member (Next: 100)
  • ***
  • Posts: 59
  • Rating: +0/-0
    • View Profile
Re: Negative/Opposite Numbers
« Reply #5 on: November 27, 2012, 11:29:26 pm »
couldn't you leave the parentheses
Code: [Select]
1=EXP1*2-1→Z
or if the "true" isn't always 1
Code: [Select]
0<EXP1*2-1→Z
Hmm, this didn't seem to work for me in my program. I guess Axe really doesn't support negative numbers in equasions. I figured out a different way to do it, and it works fine. Thanks for the help all!

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Negative/Opposite Numbers (SOLVED)
« Reply #6 on: November 28, 2012, 08:46:11 am »
couldn't you leave the parentheses
Code: [Select]
1=EXP1*2-1→Z
or if the "true" isn't always 1
Code: [Select]
0<EXP1*2-1→Z
Hmm, this didn't seem to work for me in my program. I guess Axe really doesn't support negative numbers in equasions. I figured out a different way to do it, and it works fine. Thanks for the help all!

What doesn't Axe support for negative numbers? Keep in mind that the normal, unsigned comparison operators mostly don't work for signed numbers, but there are the signed comparison operators: ==, ≠≠, <<, ≤≤, >>, and ≥≥.

Offline Derf321

  • LV3 Member (Next: 100)
  • ***
  • Posts: 59
  • Rating: +0/-0
    • View Profile
Re: Negative/Opposite Numbers (SOLVED)
« Reply #7 on: November 30, 2012, 12:49:34 pm »
Nevermind, I was using an older version of axe that probably didn't support it.