SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Quick entry instructions if

    How to convert a normal record, the statement:
    Code:
    zmienna=x^50?zmienna:nowa_wartosc;
    ?
    And what is this character: "^"?

    I tried:
    Code:
    if(x^50)
    {
      zmienna=zmienna; // I know...meaningless?
    }
    else
    {
      zmienna=nowa_wartosc;
    }
    But it probably is wrong.

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,332
    Mentioned
    192 Post(s)
    Tagged
    4 Thread(s)
    What is the context of your question?
    From whence does this data come? If it was a form (input from the user) there is no way to be sure of the significance of that expression.

    More importantly, don't forget that "^" (commonly called the Caret) is simply another ASCII character. Again, the meaning of it is purely subjective. We tend to assume it represents an exponential operator. But that may not be true.
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  3. #3
    SitePoint Member
    Join Date
    Jun 2012
    Location
    au2650
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fz21z View Post
    And what is this character: "^"?
    The code you present is a ternary operator which you correctly changed to a if/else

    Code:
    zmienna=x^50?zmienna:nowa_wartosc;
    this part
    Code:
    x^50
    JavaScript needs to evaluate that to a true or false for it to work.

    the "^" in this case is a "bitwise XOR" (A bit of home work for you).

    So depending on what the "X" value is in relation to "50" the result will a true of false

    drop this into a web page and play..



    Code:
    var bw;
    bw = '';
    bw = 3^4?'yes':'no';
    alert(bw);
    try 3^3 as well


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •