This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Animate Your Name Forum

View Course

39 points
1da79ca3434ab0d2b992e96f7aab9c4e?s=140&d=retro
Submitted by
teddygrl
over 2 years ago

Math Glitch

Using the code editor
document.write(111111111*111111111);

displays: 12345678987654320

that's the wrong answer...but because I'm just learning how to code, I don't know why it's creating a problem, just thought I'd give you guys a heads up


0 votes

permalink

Hi teddygrl,

Web browsers aren't great at doing big math, but my calculator gives me this answer to your equation and that matches what your browser is telling you.

1.234567898765432e+16

What answer were you hoping for?

3698 points
55df2afa95e3787b9200005e_359368177
Submitted by
Judy
over 2 years ago

1 Comment

56c635067700a184c087136292e98054?s=140&d=retro John Bacon over 2 years ago

The answer to 111111111111111111 is 12345678987654321. The rightmost digit in the answer should be 1 not 0. Since 11=1 and no other digits contribute to the rightmost digit.


0 votes

permalink

The web browser appears to display only 16 significant digits, then floor the rest without telling the user. But the question asks for big numbers to multiply together, and some people like to test using LARGE numbers where they know the answer to the exact digit..

For example, I tested 9999999999*9999999999=99999999980000000001.
The answer displayed was 99999999980000000000, so I went to the q and a section to find the limitations of the system.

Some limit should be introduced since all is fine as long as both numbers multiplied are 8 or fewer digits long. Getting the wrong answer is confusing to beginner programmers who don't know about limits.

52 points
56c635067700a184c087136292e98054?s=140&d=retro
Submitted by
John Bacon
over 2 years ago