For questions about Chrome DevTools, checkout the
google-chrome-devtools tag on StackOverflow.
For questions about Chrome, check the google-chrome
tag. If you think you've found a Chrome bug, check out our
feedback page for more details on how to file it.
Welcome! Please use this template for reporting documentation issues on https://developers.google.com/web/.
For questions about Chrome DevTools, checkout the
google-chrome-devtools
tag on StackOverflow. For questions about Chrome, check thegoogle-chrome
tag. If you think you've found a Chrome bug, check out our feedback page for more details on how to file it.Page Affected: https://developers.google.com/web/TODO
What needs to be done?
The web page https://developers.google.com/web/updates/2018/03/emscripting-a-c-library is an excellent example of using Emscripten but the example Fibonacci program on the page is incorrect. Instead of returning Fib(n), it returns Fib(n+1). For example, Fib(5) = 5, but the supplied function returns 8. See http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibtable.html for an authoritative list of Fibonacci numbers.
This does not affect the value of the page, but is disconcerting to math-ocd people :-).
The problem can be fixed in many ways, but I fixed it like this:
include
EMSCRIPTEN_KEEPALIVE int fib(int n) { int i, t, a = 0, b = 1;
if (n <= 0) { return 0; }
for (i = 1; i < n; i++) { t = a + b; a = b; b = t; } return b; }
type-something
label has been added.section-something
label has been added.