Re: C: Dividieren

Carsten Weinberg <[email protected]>
Newsgroups gmane.linux.suse.programming
Message-ID <[email protected]>
volker wirth wrote:

>Hallo,
>das hört sich vermutlich etwas seltsam an, aber:
>ich benutze Dev-C++4 mit cygnus;
>Code:
>
>float z = (1 / 2);
>printf("%f", z);
>
>und er sagt mir: 0.000000
>
>
>  
>

wie wärs mit

  float z = (1.0 / 2.0);
  printf("%f\n", z);

ansonsten macht du eine Integer Division. Und da stimmt dann dein Ergebnis.




-- 
Um die Liste abzubestellen, schicken Sie eine Mail an:
    [email protected]
Um eine Liste aller verfügbaren Kommandos zu bekommen, schicken
Sie eine Mail an: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.