Newsgroups: comp.lang.javascript
From: Jorge <jo...@jorgechamorro.com>
Date: Mon, 29 Sep 2008 13:02:58 -0700 (PDT)
Local: Mon, Sep 29 2008 4:02 pm
Subject: Re: Need some JavaScript puzzles
On Sep 28, 9:04 pm, dhtml <dhtmlkitc...@gmail.com> wrote:
> Jorge wrote: Now that you say it... yes. I completely forgot its existence :-) > > On Sep 24, 3:14 am, dhtml <dhtmlkitc...@gmail.com> wrote: > >> 1. write a function return the binary representation of a given number > >> in "ON" and "OFF". For example, if the input is 47 (101111 in binary), > >> it should return "ON OFF ON ON ON ON". > >http://jorgechamorro.com/cljs/016/ > You could have used toString(radix). > var n = 101111; > n.toString(2).replace(/1/g, "ON "). Thanks for posting that because I have played with it a little and I (3.1416).toString(2) -> and that it will fail as miserably as mine and without warning (for javascript:alert((9007199254740991).toString(2)) -> While writing 'my version', I was going to 'logically' test the bits javascript:alert(9007199254740991 & Math.pow(2,31)) === -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||