JRS: In article <4c*************************@posting.google.com> , seen
in news:comp.lang.javascript, chirs <ym*@kicon.com> posted at Sun, 30
Nov 2003 21:36:27 :-
I'd like to use a var to hold a Hex number.
Variables hold IEEE Doubles as the only form of number, except maybe in
future. You can, however, use Hex notation to specify the contents of a
variable.
But in this code:
var a = "ffff00"
a is a string. var a=ffff00 will not work either. How can I put a
Hex number ffff00 into a var?
var a = 0xffff00 // 1. to give a literal in Hex
var HS = "ffff00"
var a = +("0x"+HS) // 2. using existing string
var a = parseInt(HS, 16) // 3. normal, using existing string
Here 2 & 3 give different result with different illegal strings HS; try
"fated" & "defeat"; I prefer the former.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.