On Fri, Nov 02, 2007 at 10:04:48PM +0000, Pete French wrote: > int > main(int argc, char *argv[]) > { > if(atof("3.2") == atof("3.200")) > puts("They are equal"); > else > puts("They are NOT equal!"); > return 0; > }
Since the program as defined above does not include any prototype for atof(), its return value is assumed to be int. The i386 code for the comparison is therefore: movl $.LC0, (%esp) call atof movl $.LC1, (%esp) movl %eax, %ebx call atof cmpl %eax, %ebx je .L7 Note that this is comparing the %eax returned by each atof(). Since atof() actually returns a double in %st(0) and %eax is a scratch register, the results are completely undefined. Unfortunately, I can't explain why an i386 would be different to an amd64 in i386 mode. -- Peter Jeremy Please excuse any delays as the result of my ISP's inability to implement an MTA that is either RFC2821-compliant or matches their claimed behaviour.
pgp9NYp3Hzs1H.pgp
Description: PGP signature