[FoRK] Re: 2+2=5986

Corinna < corinna.schultz at gmail.com > on > Fri Aug 4 09:18:27 PDT 2006

Andy Armstrong <andy <at> hexten.net> writes:

>
>      answer = 2 + 2;
>      printf("The answer is %d\n");

>      result = 21.0 / 7.0;
>      printf("The result is %d\n", result);

> On my system the first shows that 2 + 2 = -1078787380 and the second  
> does indeed output "The result is 0". Can you see why? :)
> 

The second one is easy to see. The first one... is it that the %d grabs whatever
is next in memory, even if you don't provide an argument? That's devious. I'm
reminded of why I like Java... and perl for that matter.
:)

(disclaimer: yes, I know every language has it's useful sphere. I'm not starting
a language flame-war :)  )

-Corinna



More information about the FoRK mailing list