Timeline for answer to Why the control goes in "else" part? by user1202136
Current License: CC BY-SA 3.0
Post Revisions
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 15, 2012 at 11:30 | vote | accept | user1593308 | ||
| Aug 14, 2012 at 23:19 | comment | added | user1202136 | @MichaelBurr: You are right. I fixed the code above. Thanks a lot for noticing. | |
| Aug 14, 2012 at 23:18 | history | edited | user1202136 | CC BY-SA 3.0 |
Fixed code
|
| Aug 14, 2012 at 21:21 | comment | added | Michael Burr |
@user1202136: not even close - as H2CO3 mentions, the posted code has UB, and the amd64 doesn't simply pass varargs on the stack as on 32-bit x86 (at least for floating point args - I don't recall all the details), so you get printed data that really has nothing to do with the floating point values you're passing. The actual IEEE hex representations for 0.8 are: 3f4ccccd (32-bit float), 3fe99999a0000000 (32-bit float converted to 64-bit double), and 3fe999999999999a (double).
|
|
| Aug 14, 2012 at 20:09 | comment | added | user1202136 | @MichaelBurr: I ran it on Ubuntu 12.04 / 64 bits on an Intel processor. Why? Don't you get the same values? | |
| Aug 14, 2012 at 18:12 | comment | added | Michael Burr | @user1202136: what platform did you run that test on? | |
| Aug 14, 2012 at 16:36 | history | answered | user1202136 | CC BY-SA 3.0 |