[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]

/prog/ - Programming

Programming board

Catalog

8chan Bitcoin address: 1NpQaXqmCBji6gfX8UgaQEmEstvVY7U32C
The next generation of Infinity is here (discussion) (contribute)
A message from @CodeMonkeyZ, 2ch lead developer: "How Hiroyuki Nishimura will sell 4chan data"
Name
Email
Subject
Comment *
File
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Embed
(replaces files and can be used instead)
Options
Password (For file and post deletion.)

Allowed file types:jpg, jpeg, gif, png, webm, mp4, pdf
Max filesize is 8 MB.
Max image dimensions are 10000 x 10000.
You may upload 1 per post.


e33be0 No.1604

Sorry for the small question, but does anyone know if Javascript cares whether you have numbers in power of twos? i.e. is it any different if I decide the max value for my variable should be 100, or if I decide it should be 64?

And if not, can I make it care for optimization reasons? (millions of numbers in an array cluster)

e3fc65 No.1605

This is microoptimization to a whole new level. What makes you think 64 will be faster than 100?

cca26b No.1607

>>1604
>Sorry for the small question, but does anyone know if Javascript cares whether you have numbers in power of twos?

See:
>http://www.2ality.com/2012/04/number-encoding.html
tl;dr - No, JS handles all numbers the same way.

>millions of numbers in an array cluster

Changing the maximum value from 100 to 64 wouldn't make any difference here even if JS did let you decide the widths of integers - 100 and 64 take the same number of bits to represent (1100100 vs 1000000).

5064a1 No.1627

>>1605
Less bits to handle numbers, I don't know much about how this stuff works, but if you only need to store 64 possible values, I'd imagine the computer can optimize that better than if tries to account for 9,007,199,254,740,991 possible values when it doesn't need to. Sorry for the exaggerated example.

>>1607
I see, thanks. That's a pretty good article. I think I meant 64 values, as in 0-63

551138 No.1743

>>1627
The most basic type of data a CPU can retrieve from memory and handle is a byte, or at least with most current architectures. That means, the CPU is probably going to treat 00000001 and 11111111 the same way, even though they are 1 and 255, respectively.

Anyway, even the performance difference between int 32 (4 bytes) and a byte is negligible, so the difference between two 8 bit values would be even smaller. Not to take into account most JS implementations will probably just make all numbers 32/64 bits, as >>1607 said.

Anyway, if you actually needed to make a program that took advantage of stuff like this, you would probably not even consider JavaScript for it.

e80d57 No.1755




[Return][Go to top][Catalog][Post a Reply]
Delete Post [ ]
[]
[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]