Explain how basic code is working - Eloquent JavaScript book -


here code - https://github.com/novaugust/code-wyoming-wiki/blob/master/day-21.md

here info if want bigger picture (eloquent javascript marijn haverbeke) - http://eloquentjavascript.net/00_intro.html

i'm new in computer world of programming , don't understand how simple digits (00110001 etc.) mean 1 + 2 + ... + 10 = 55

i understand

var total = 0, count = 1; while (count <= 10) { total += count; count += 1; } console.log(total) 

and

console.log(sum(range(1, 10)));

but 00110001 00000000 00000000 not 'magic' me. can explain in 'simple mode'? btw is embarrassing stop on page 4...

from understand you're struggling concept of binary. common lot of people, life long coders (you don't need know except hardware stuff).

essentially binary works identical base-10 number system know where: 123 = 1 x 100 + 2 x 10 + 3 x 1 or 123 = 1 x 10^2 + 2 x 10^1 + 3 x 1^0 (^ means exponent)

in binary there 2 digits, 0 , 1. place-value idea above same:

1001:[1 x 2^3] + [0 x 2^2] + [0 x 2^1] + [1 x 2^0]

to determine value of 1001 perform calculation above. number grows increase number of place values increasing exponent power of 2.

note: 2^n 2^n-1...2^n-n -> formula binary number n+1 digits 64 + 32 + 16 + 8 + 4 + 2 + 1 = 1111111 -> first 7 binary place values

binary typically not human-readable, posses cool features make easier use. notably converting binary hexadecimal(base 16 number system) cinch.

it may start small, found once comfortable 1111, 1010, 0001 etc. more confident binary whole.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -