How are you running the code? Assertions on or off?
f2 is NaN (line 5, f2=f1).
With assertions off, the "assert" statement won't do anything.
f3 become 1.5
Then f3+f2 is i.1 + NaN which is always NaN.
If you run with assertions on, you'll get a different answer as the assert will cause an axception (NaN==NaN is false).
Is this from K&B?
You should quote your sources.