need help with code

Results 1 to 2 of 2

Thread: need help with code

  1. #1
    doubtfire Guest

    Default need help with code

    i want to know how this piece of code works<BR>&#060;SCRIPT LANGUAGE="JavaScript"&#062; <BR>&#060;!-- <BR> var x = new Number(16); <BR> var y = x.toString(15); <BR>document.write( y);//returns 11<BR>// --&#062; <BR>&#060;/SCRIPT&#062;

  2. #2
    Steve Magara Guest

    Default RE: need help with code

    It looks like it creates a number object with the value 16, then prints it out in base 15. Normally the radix used would be 10, 16 or 2. Try this:<BR>&nbspdocument.write("&ltBR&gtHex: " + x.toString(16))<BR>&nbspdocument.write("&ltBR&gtDe cimal: " + x.toString(10))<BR>&nbspdocument.write("&ltBR&gtBi nary: " + x.toString(2))<BR><BR>Hope it helps.

Posting Permissions

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