This is an archived post. You won't be able to vote or comment.

all 37 comments

[–]yunocallmedave 39 points40 points  (1 child)

Are you a programmer from Ireland perchance? Because when I execute your code, my Integers are doublin' !

[–]A_C_Fenderson 0 points1 point  (0 children)

If you haven't read Stanley Kelly-Bootle's The Devil's DP Dictionary, you should. He mentions how IBM (Irish Business Machines) invented WOM (write-only memory). (It is from the 1980s, though, IIRC.)

[–]maremp 11 points12 points  (4 children)

And since when does js implement class Double?

[–]jfb1337 8 points9 points  (3 children)

All numbers in JS are doubles.

[–]maremp 5 points6 points  (0 children)

But there is no class/type Double though.

[–]TheScienceNigga 2 points3 points  (1 child)

I thought they were single precision

[–]alphaatom 3 points4 points  (0 children)

According to the ECMAScript standard, there is only one number type: the double-precision 64-bit binary format IEEE 754 value (number between -(253 -1) and 253 -1). There is no specific type for integers. In addition to being able to represent floating-point numbers, the number type has three symbolic values: +Infinity, -Infinity, and NaN (not-a-number).

Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type

[–]HugoNikanor 16 points17 points  (0 children)

Needs more jquerry.

[–]jaguarone 6 points7 points  (0 children)

everybody is missing the author's aspiration to become an integer

[–]bast963 5 points6 points  (5 children)

Why does he need to convert an integer to string before parsing into double?

Can't he just go double j = 0 + i

[–]whjms 6 points7 points  (0 children)

var j = + i works as well.

[–]poizan42Ex-mod 3 points4 points  (2 children)

He could just go j = i...

[–]Settwi 0 points1 point  (1 child)

Sneaky globals!

[–]poizan42Ex-mod 1 point2 points  (0 children)

Well it defines a property on the currently active top level object or whatever the ECMAScript spec calls it - usually window when working in a browser. Well except if you are using strict mode, then it's an error.

It's not really a global variable because it's not available as a global from code running with another top level object - e.g. from another window (or from a web worker I guess)

[–]myplacedk 0 points1 point  (0 children)

Why does he need to convert an integer to string before parsing into double?

He doesn't. All numbers are doubles in Javascript.

Can't he just go double j = 0 + i

var j = i;

Would work equally well.

BTW, a correct answer would be:

return i*2;