Re: Trying to use gdb on OS X

new topic     » goto parent     » topic index » view thread      » older message » newer message
mattlewis said...

Could you try the following program?

#include <stdio.h> 
 
void convert_double( double d ){ 
	long l = (long) d; 
	unsigned long u = (unsigned long) d; 
	printf("%g -> %lx %lx\n", d, l, u ); 
} 
 
int main(){ 
	convert_double( (double) -1 ); 
	convert_double( (double) 0xdeadbeef ); 
	return 0; 
} 
 

I tried this two different ways:

$ gcc -m32 test.c -o test && ./test 
-1 -> ffffffff ffffffff 
3.73593e+09 -> 80000000 deadbeef 
 
gcc -m64 test.c -o test && ./test 
-1 -> ffffffffffffffff ffffffffffffffff 
3.73593e+09 -> deadbeef deadbeef 

Matt


OS X results:

jason$ ./test-dbl32 
-1 -> ffffffff 0 
3.73593e+09 -> 80000000 deadbeef 
 
jason$ ./test-dbl64 
-1 -> ffffffffffffffff ffffffffffffffff 
3.73593e+09 -> deadbeef deadbeef 

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu