Shop OBEX P1 Docs P2 Docs Learn Events
~~ Operator — Parallax Forums

~~ Operator

NewzedNewzed Posts: 2,503
edited 2007-10-27 00:19 in Propeller 1
Is out[noparse][[/noparse]a]~~
the same as out[noparse][[/noparse]a] := 0

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Yesterday is history, tomorrow is a mystery, and today is a gift.

That is why they call it the present.

Don't have VGA?
Newzed@aol.com
·

Comments

  • boeboyboeboy Posts: 301
    edited 2007-10-25 20:22
    Yes. But it is outa[noparse][[/noparse]pin]~~ pin being the output pin.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My computer, http://forums.parallax.com/showthread.php?p=630466
  • NewzedNewzed Posts: 2,503
    edited 2007-10-25 20:26
    Then it follows that outa[noparse][[/noparse]pin]~

    is the same as outa[noparse][[/noparse]pin] := 1

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-10-25 20:31
    It's the other way around: ~ resets to 0; ~~ sets to 1.

    Also, don't forget that, when used with variables, the ~~ operator sets all the bits to 1s.

    -Phil
  • NewzedNewzed Posts: 2,503
    edited 2007-10-25 20:50
    Phil, are you saying that outa[noparse][[/noparse]pin]~~ is the same as outa[noparse][[/noparse]pin] := 1

    and that outa[noparse][[/noparse]pin]~ is the same as outa[noparse][[/noparse]pin] := 0

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-10-25 20:57
    yes he is
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-10-25 21:14
    Yup.
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-10-25 21:15
    told you [noparse]:)[/noparse]
  • cgraceycgracey Posts: 14,133
    edited 2007-10-25 21:42
    Wait. There's more.

    When you use variable~ or variable~~ in an expression, the value returned is the value BEFORE the clearing or setting.

    Example:

    ··if Flag~·········'Read and clear flag
    ··· DoSomething·· ·'Do something if flag was set

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-10-25 22:26
    Wait, wait. There's more yet!

    When used as a prefix, the meaning of these two operators changes entirely. Rather than pre-setting or -clearing a variable (which wouldn't be all that useful), it sign extends either bit 7 (~variable) or bit 15 (~~variable).

    -Phil
  • Ken PetersonKen Peterson Posts: 806
    edited 2007-10-26 01:21
    er....that's confusing. But useful!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    The more I know, the more I know I don't know.· Is this what they call Wisdom?
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-26 07:05
    ... and still three remarkssmile.gif

    How to remember:
    ~ looks "less" than ~~ and 0 is less then 1

    And the "1" is not a good alternative: x~~ corresponds to x := TRUE

    And though it makes programs UNREADABLE it is faster than the corresponding assignment...
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-10-26 07:20
    Readability, of course, is relative to familiarity. The same could've been said of x++ when it was first introduced (in C?). Now it's ubiquitous.

    -Phil
  • rjo_rjo_ Posts: 1,825
    edited 2007-10-27 00:19
    Wait there's more... when you get to my age, if you get it wrong the first time... you can just kiss it good bye.
Sign In or Register to comment.