JavaScript : 64 bits repercussions on numbers -


i'm reading eloquent javascript, , got "stuck" in explanation, @ first thought i'd skip it, tried come it, , cant understand it, tried googling 64 bits repercussions , stuff failed find answer.

i don't stuff such as, 10^3? why limited 3 decimal digits? tried typing 1.99999999999 , worked, there place can understand sentence without skipping it? read somewhere javascript has problems approximation, 2.000000000 may 2.000000000001 lead problems, part of book doesnt seem similar me.

any appreciated thanks.

this part dont understand this book

this 144 looks in bits:  0100000001100010000000000000000000000000000000000000000000000000  number above has 64 bits. numbers in javascript do. has 1 important repercussion: there limited amount of different numbers can expressed. 3 decimal digits, numbers 0 999 can written, 10^3 = 1000 different numbers. 64 binary digits, 2^64 different numbers can written. lot, more 10^19 (a 1 nineteen zeroes).  not whole numbers below 10^19 fit in javascript number though. one, there negative numbers, 1 of bits has used store sign of number. bigger issue non-whole numbers must represented. this, 11 bits used store position of fractional dot within number.  leaves 52 bits. whole number less 2^52 (which more 10^15) safely fit in javascript number. in cases, numbers using stay below that, not have concern ourselves bits @ all. good. have nothing in particular against bits, need terrible lot of them done. when @ possible, more pleasant deal bigger things. 

repercussion part of english sentence, it's not technical term: 'this has 1 important repercussion' means he's going point out important effect of he's been talking about, in case javascript can express limited amount of numbers, , can calculate amount.

ten power of 3 (i.e. ten cubed) 1000, that's basic maths. he's using example, explain how many numbers can written 3 digits (1000 can written, i.e. of numbers 0 999). likewise, if had 4 digits, write ten power of 4 numbers (10,000, i.e. of numbers 0 9999). it's ten power of because use decimal number system which, definition, based on powers of ten (look number/base systems, if you're still unsure: decimal, binary, hexadecimal , octal ones used in computing).

then goes on talk binary numbers, number system in javascript (and virtually programming languages) uses: rather 10 power of something, binary it's 2 power of something, because binary base 2, whereas decimal base 10. so, again, when want find amount of numbers can express, work out base power of number of digits have, because javascript can store 64 binary ('base 2') digits, we'd need work out 2 power of 64, happens big number -- try in calculator or on google (enter 2^64 search box)!

however, says, in reality not of these available, because of how decimal , negative numbers stored. if you're interested in more detail, i'd recommend read book code: hidden language of computer hardware , software charles petzold, because gives solid simple explanations new this. on bright side, need know internal details of javascript number system in order write javascript! knowledge good.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -