douglascrockford / howjavascriptworks

Programs from the book _How JavaScript Works_
319 stars 53 forks source link

Concerning is_big_integer #6

Closed bunglegrind closed 5 years ago

bunglegrind commented 5 years ago

Dear Mr. Crockford, I'm puzzled about the function is_big_integer. Specifically, the function only checks if the input is an array and its first element is the string "+" or "-", but shouldn't it also verify that the other input array elements are actual megadigits (that is, numbers, > 0 and < radix)?

btw, I really appreciated your book.

Cheers.

douglascrockford commented 5 years ago

You could, but I don't think it is necessary in practice.

Thanks.

cipherlogs commented 2 years ago

@bunglegrind Hello,

Mr Crockford represented the following 9000000000000000000 = (8650752 16777216^0) + (7098594 16777216^1) + (31974 * 16777216^2)

can you please help me figure out the formula that it has been used, I can't figure out how come we got 8650752 and 7098594...

I would appreciate the help. Thank you

bunglegrind commented 2 years ago

The usual way for radix conversion (decimal to 16777216 in this case):


9000000000000000000  % 16777216 = 8650752 
(9000000000000000000  / 16777216) % 16777216 = 7098594

% = remainder of the integer division / = integer division

Anyway, this is an issue tracker. I don't know if there's a forum or something to discuss the book...

cheers

cipherlogs commented 2 years ago

@bunglegrind Thank you so much.

I wish if there was a forum to discuss this book. such a quality book.

it seems that you found this book 2years ago, I would love to know if you came across other materials that compare to this book ( learning while building real stuff, while writing clean and good javascript )

my best to you.

bunglegrind commented 2 years ago

Not really. Probably the articles/books more similar are the ones about functional programming with javascript.