Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Converting a variable to hex and binary

Reply
Thread Tools

Converting a variable to hex and binary

 
 
Cogito
Guest
Posts: n/a
 
      06-22-2004
Is there a javascript command to convert and display a variable in
hexadecimal and/or in binary?
 
Reply With Quote
 
 
 
 
rf
Guest
Posts: n/a
 
      06-22-2004

"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.


 
Reply With Quote
 
 
 
 
Cogito
Guest
Posts: n/a
 
      06-22-2004
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….?
 
Reply With Quote
 
rf
Guest
Posts: n/a
 
      06-22-2004

"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.


 
Reply With Quote
 
Cogito
Guest
Posts: n/a
 
      06-22-2004
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.
 
Reply With Quote
 
nice.guy.nige
Guest
Posts: n/a
 
      06-22-2004
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!


 
Reply With Quote
 
rf
Guest
Posts: n/a
 
      06-22-2004

"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.


 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      06-22-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting binary sid's to a hex string LittlePython Python 2 06-09-2006 09:00 PM
hex string to hex value tim Python 8 11-23-2005 06:27 PM
Hex Color Codes - Hex 6 <=> Hex 3 lucanos@gmail.com HTML 10 08-18-2005 11:21 PM
hex value in string back to real hex value jack Python 4 09-08-2004 07:11 AM
hex(-5) => Futurewarning: ugh, can't we have a better hex than '-'[:n<0]+hex(abs(n)) ?? Bengt Richter Python 6 08-19-2003 07:33 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57