Converting a variable to hex and binary

Discussion in 'HTML' started by Cogito, Jun 22, 2004.

  1. Cogito

    Cogito Guest

    Is there a javascript command to convert and display a variable in
    hexadecimal and/or in binary?
    Cogito, Jun 22, 2004
    #1
    1. Advertising

  2. Cogito

    rf Guest

    "Cogito" <> wrote in message
    news:...
    > Is there a javascript command to convert and display a variable in
    > hexadecimal and/or in binary?


    Yes.

    --
    Cheers
    Richard.
    rf, Jun 22, 2004
    #2
    1. Advertising

  3. Cogito

    Cogito Guest

    On Tue, 22 Jun 2004 06:48:51 GMT, "rf" <> wrote:

    >
    >"Cogito" <> wrote in message
    >news:...
    >> Is there a javascript command to convert and display a variable in
    >> hexadecimal and/or in binary?

    >
    >Yes.


    And the command is….?
    Cogito, Jun 22, 2004
    #3
  4. Cogito

    rf Guest

    "Cogito" <> wrote in message
    news:...
    > On Tue, 22 Jun 2004 06:48:51 GMT, "rf" <> wrote:
    >
    > >
    > >"Cogito" <> wrote in message
    > >news:...
    > >> Is there a javascript command to convert and display a variable in
    > >> hexadecimal and/or in binary?

    > >
    > >Yes.

    >
    > And the command is..?


    It's not a command, it's a method.

    var num = 42;
    var hex = num.toString(16);
    alert(hex);
    alert(num.toString(2));

    --
    Cheers
    Richard.
    rf, Jun 22, 2004
    #4
  5. Cogito

    Cogito Guest

    On Tue, 22 Jun 2004 07:10:55 GMT, "rf" <> wrote:

    >
    >"Cogito" <> wrote in message
    >news:...
    >> On Tue, 22 Jun 2004 06:48:51 GMT, "rf" <> wrote:
    >>
    >> >
    >> >"Cogito" <> wrote in message
    >> >news:...
    >> >> Is there a javascript command to convert and display a variable in
    >> >> hexadecimal and/or in binary?
    >> >
    >> >Yes.

    >>
    >> And the command is..?

    >
    >It's not a command, it's a method.
    >
    >var num = 42;
    >var hex = num.toString(16);
    >alert(hex);
    >alert(num.toString(2));


    Thanks.
    Now I know the method and the correct javascript parlance.
    Cogito, Jun 22, 2004
    #5
  6. While the city slept, rf <> feverishly typed:

    > "Cogito" <> wrote in message
    > news:...
    >> On Tue, 22 Jun 2004 06:48:51 GMT, "rf" <> wrote:
    >>
    >>>
    >>> "Cogito" <> wrote in message
    >>> news:...
    >>>> Is there a javascript command to convert and display a variable in
    >>>> hexadecimal and/or in binary?
    >>>
    >>> Yes.

    >>
    >> And the command is..?

    >
    > It's not a command, it's a method.

    [...]

    Hang on... first your say "Yes" to the question "Is there a [...] command",
    then you say "It's not a command"... so your first post was wrong? ;-)

    Cheers,
    Nige

    --
    Nigel Moss.

    Email address is not valid. . Take the dog out!
    http://www.nigenet.org.uk | Boycott E$$O!! http://www.stopesso.com
    In the land of the blind, the one-eyed man is very, very busy!
    nice.guy.nige, Jun 22, 2004
    #6
  7. Cogito

    rf Guest

    "nice.guy.nige" <> wrote in message
    news:...

    > >> And the command is..?

    > >
    > > It's not a command, it's a method.

    > [...]
    >
    > Hang on... first your say "Yes" to the question "Is there a [...]

    command",
    > then you say "It's not a command"... so your first post was wrong? ;-)


    Absolutely.

    Good to see there are *some* sharp people still here :)

    --
    Cheers
    Richard.
    rf, Jun 22, 2004
    #7
  8. Cogito

    Andy Dingley Guest

    Cogito <> wrote in message news:<>...
    > Is there a javascript command to convert and display a variable in
    > hexadecimal and/or in binary?


    Number.toString (radix)

    Just give it the value of radix that you want - 16 or 2
    Andy Dingley, Jun 22, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    10
    Views:
    6,134
    Neredbojias
    Aug 19, 2005
  2. Bengt Richter
    Replies:
    6
    Views:
    448
    Juha Autero
    Aug 19, 2003
  3. jack
    Replies:
    4
    Views:
    574
  4. tim

    hex string to hex value

    tim, Nov 22, 2005, in forum: Python
    Replies:
    8
    Views:
    18,794
  5. LittlePython

    Converting binary sid's to a hex string

    LittlePython, Jun 7, 2006, in forum: Python
    Replies:
    2
    Views:
    1,211
    LittlePython
    Jun 9, 2006
Loading...

Share This Page