3 ms·
I have to admit, I did not understand your earlier comment until just now. Sorry about the code change, the first version was from an old memory and the new ve
by sp332 13y ago
I have to admit, I did not understand your earlier comment until just now.
Sorry about the code change, the first version was from an old memory and the new version is what happened after I stared at it for a while :) Primitive values are automatically initialized to 0 in C. As for the ratio, it will probably just give a good approximation of 1 as a gets large! Also if you have a good square root function, you can use it to find a Fibonacci number in constant time, so your ratio will always be 1 (until the square root is too big to be computed in a single instruction).
- NAFV_P 13y ago> I have to admit, I did not understand your earlier comment until just now. From the number of downvotes, I think it was mis-parsed by several HN readers. This happens to me quite often, on many a website, but I have no inkling why. > Sorry about the code change, the first version was from an old memory and the new version is what happened after I stared at it for a while No worries, I thought the original slice of code that you posted was more interesting and novel, it wouldn't have occurred to me off the top of my head. > Primitive values are automatically initialized to 0 in C. I had to look that up, good old Stack Overflow has again furnished us with an explanation. http://stackoverflow.com/questions/10089551/what-are-primitive-types-default-initialized-to-in-c http://stackoverflow.com/questions/10089551/what-are-primiti...
- mattst88 13y ago> Primitive values are automatically initialized to 0 in C. No, they're not. Automatic variables without an initializer have an indeterminate value. See http://stackoverflow.com/questions/6212921/is-un-initialized-integer-always-default-to-0-in-c http://stackoverflow.com/questions/6212921/is-un-initialized...