From: Thomas 'PointedEars' Lahn on
Ry Nohryb wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Ry Nohryb wrote:
>> > No. A "more sophisticated solution" is to fix your broken algorithm:
>> > you're parsing an amount which is less than 1 as an (probably)
>> > enormous integer
>>
>> Less than 1? You don't know what you are talking about.
>
> Yes, less than one : [0..1)

AISB.


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(a)news.demon.co.uk>
From: Ry Nohryb on
On May 28, 4:59 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
wrote:
> Ry Nohryb wrote:
>
> > You're, as usual, heavily disoriented.
>
> Yeah, maybe that is why your code also fails to solve this problem:
>
> ,-<news:52ceaeda-f3e2-4aaa-ad6f-42a640125d91(a)j9g2000vbp.googlegroups.com>
> |
> | (-Math.PI).toString(33).toFP(33)
> | --> NaN

You're not paying attention:
http://groups.google.com/group/comp.lang.javascript/msg/f0761684a6595c2a

> String.prototype.toFP= function (base, d, w, n, r, s) {
>   if (/[^0-9a-z\.+-]/i.test(this)) return NaN;
>   d= "0123456789abcdefghijklmnopqrstuvwxyz";
>   s= (r= parseInt((n= this.split('.'))[w= 0], base)) < 0 ? -1 : 1;
>   n= n[1].toLowerCase().split('');
>   while (n.length) r+= s* d.indexOf(n.shift())* Math.pow(base, --w);
>   return r;
>
> };
>
> (-Math.PI).toString(33).toFP(33)
> --> -3.141592653589793
--
Jorge.
From: Lasse Reichstein Nielsen on
Ry Nohryb <jorge(a)jorgechamorro.com> writes:

> String.prototype.toFP= function (base, digits, w, n, r) {

One argument against using unused parameters as local variable
declarations, that hasn't been mentioned yet, is that it might slow
down calling the function.

Simple test:

(function() {
function foo1(a,b,c,d,e) {
e=a;d=e;c=d;b=c;return b;
}
function foo2(a) {
var b,c,d,e;
e=a;d=e;c=d;b=c;return b;
}
var x = 42;
foo1(x);foo2(x); // Make sure they are compiled.
var t0 = Date.now();
for (var i = 0; i < 10000000; i++) {
x = foo1(x);
}
var t1 = Date.now();
for (var i = 0; i < 10000000; i++) {
x = foo2(x);
}
var t2 = Date.now();
alert([t1-t0,t2-t1]);
})()

Safari: 300, 179
Opera 10.54: 132, 116 (maybe not significant).
Chrome dev: 145, 90
Firefox and IE: no noticable difference.
(I also ran the tests with the two loops swapped, to see if going
first made a difference. It did a little in Firefox).

It also prevents the compiler from knowing the initial values
of the variables (but that should be irrelevant if they are
initialized before use on all paths anyway).

/L
--
Lasse Reichstein Holst Nielsen
'Javascript frameworks is a disruptive technology'

From: Ry Nohryb on
On May 28, 4:59 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
wrote:
> Ry Nohryb wrote:
> > Thomas 'PointedEars' Lahn wrote:
> (...)
> >> BTW, in case you have not noticed yet, like Safari, Chrome has a
> >> Developer menu (in the first main menu, below the Encoding menu item),
> >> which provides access to the Developer tools, including a script console
> >> and a debugger (which helped me to track this down).  That makes using
> >> Firebug Lite in Chrome unnecessary.
>
> > You're telling me ?
>
> Don't be so vain.

I'm not, but I was well aware of that, since a long time ago (years).

And you, Mr. knows-it-all, the master flagellator of newbies, were not
aware -until today- of that debugger (it's both in Safari and in
Chrome: exactly the same: and you open it in both using exactly the
same keystrokes: cmd+option+i) almost TWO years after its
introduction ?

How would you have called that, in your usual (and particular)
tongue ? Completely clueless ? Total cluelessness ?

Let me LOL, please. Let me ROTFLOL.
--
Jorge.
From: Thomas 'PointedEars' Lahn on
Ry Nohryb wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Ry Nohryb wrote:
>> > You're, as usual, heavily disoriented.
>>
>> Yeah, maybe that is why your code also fails to solve this problem:
>>
>> ,-<news:52ceaeda-f3e2-4aaa-ad6f-42a640125d91(a)j9g2000vbp.googlegroups.com>
>> |
>> | (-Math.PI).toString(33).toFP(33)
>> | --> NaN
>
> You're not paying attention:
> http://groups.google.com/group/comp.lang.javascript/msg/f0761684a6595c2a

It is comparably hard to follow your amok-posting.

Further, we should define the Jorg tropy of code as a measure of its
unreadability; once code as achieved a Jorgtropy greater than 0, that
can only increase with further edits.


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(a)news.demon.co.uk>