Mail Archives: djgpp/1999/12/05/03:41:14
This is a multi-part message in MIME format.
------=_NextPart_000_002E_01BF3ED6.B2B086E0
Content-Type: text/plain;
charset="big5"
Content-Transfer-Encoding: quoted-printable
Hi there!
try changing 5/9 to 5.0/9.0
The compiler may be interpreting it as a n integer operation, and as =
such, it will truncate de decimals, effectively doing 0 * (f-32).
Hope this helps!
Pablo M. Dotro
pyd AT sion DOT com pdotro AT USSEnterprise DOT com
pdotro AT labs DOT df DOT uba DOT ar ICQ#: 18144918
http://www.usuarios.sion.com/abismo
----- BEGIN GEEK CODE BLOCK -----
Version 3.12
GCS/S/IT/CM d- s: a23 c++$ UL P+ E W++ N++ o K- w
O? M V? PS PE- Y+ PGP>+ t++ 5+ X+ R+>+++ tv b++ DI? D++
G++ e h! r- y+
-----END GEEK CODE BLOCK -----
(para decodificar el bloque, visite www.geekcode.com)
----- Original Message -----=20
From: Jason Yip=20
Newsgroups: comp.os.msdos.djgpp
To: djgpp AT delorie DOT com=20
Sent: Sunday, December 05, 1999 12:03 AM
Subject: Why "c" is always zero??
Can anyone tells me why the value of "c" is always equal to zero??
How can I correct this?
Thanks a lot!!
#include <stdio.h>
float ftc(n)
int n;
{
float c, f; int i;
for (i=3D0;i<=3Dn;i++){
c=3D5/9*(f-32);
}
return c;
}
main ()
{
float c, f=3D0; int i=3D0;
do
{
c=3Dftc(i);
printf("\t\t F=3D%.2f \t\t C=3D%.2f\n",f,c);
f++;
i++;
} while (i<=3D100);
}
------=_NextPart_000_002E_01BF3ED6.B2B086E0
Content-Type: text/html;
charset="big5"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Dbig5" http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2919.6307" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi there!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>try changing 5/9 to =
5.0/9.0</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>The compiler may be interpreting it as =
a n integer=20
operation, and as such, it will truncate de decimals, effectively doing =
0 *=20
(f-32).</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Hope this helps!</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Pablo M. Dotro<BR><A=20
href=3D"mailto:pyd AT sion DOT com">pyd AT sion DOT com</A> &nbs=
p; =20
<A =
href=3D"mailto:pdotro AT USSEnterprise DOT com">pdotro AT USSEnterprise DOT com</A><BR>=
<A=20
href=3D"mailto:pdotro AT labs DOT df DOT uba DOT ar">pdotro AT labs DOT df DOT uba DOT ar</A> &nbs=
p; =20
ICQ#: 18144918<BR><A=20
href=3D"http://www.usuarios.sion.com/abismo">http://www.usuarios.sion.com=
/abismo</A></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>----- BEGIN GEEK CODE BLOCK =
-----<BR>Version=20
3.12<BR>GCS/S/IT/CM d- s: a23 c++$ UL P+ E W++ N++ o K- w<BR>O? M V? PS =
PE- Y+=20
PGP>+ t++ 5+ X+ R+>+++ tv b++ DI? D++<BR>G++ e h! r- =
y+<BR>-----END GEEK=20
CODE BLOCK -----<BR>(para decodificar el bloque, visite <A=20
href=3D"http://www.geekcode.com">www.geekcode.com</A>)<BR></FONT></DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
<DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV=20
style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
<A href=3D"mailto:manman AT netteens DOT net" =
title=3Dmanman AT netteens DOT net>Jason Yip</A>=20
</DIV>
<DIV style=3D"FONT: 10pt arial"><B>Newsgroups:</B> =
comp.os.msdos.djgpp</DIV>
<DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
href=3D"mailto:djgpp AT delorie DOT com"=20
title=3Ddjgpp AT delorie DOT com>djgpp AT delorie DOT com</A> </DIV>
<DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Sunday, December 05, 1999 =
12:03=20
AM</DIV>
<DIV style=3D"FONT: 10pt arial"><B>Subject:</B> Why "c" is always =
zero??</DIV>
<DIV><BR></DIV>
<DIV><FONT face=3D"Times New Roman">Can anyone tells me why the value =
of "c" is=20
always equal to zero??</FONT></DIV>
<DIV><FONT size=3D2>How can I correct this?</FONT></DIV>
<DIV><FONT size=3D2>Thanks a lot!!</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Times New Roman">#include <stdio.h><BR>float=20
ftc(n)<BR>int n;<BR>{<BR>float <FONT color=3D#0000ff>c</FONT>, f; int=20
i;<BR> for (i=3D0;i<=3Dn;i++){<BR> <FONT=20
=
color=3D#0000ff>c=3D5/9*(f-32)</FONT>;<BR> &=
nbsp; =20
}<BR>return c;<BR>}<BR>main ()<BR>{<BR>float c, f=3D0; int=20
i=3D0;<BR>do<BR>{<BR><FONT color=3D#0000ff></FONT><FONT=20
face=3D"Times New Roman">c=3Dftc(i);<BR></FONT></FONT><FONT=20
face=3D"Times New Roman">printf("\t\t F=3D%.2f \t\t =
C=3D%.2f\n",f,<FONT=20
color=3D#0000ff>c</FONT>);<BR>f++;<BR>i++;<BR>} while=20
(i<=3D100);<BR>}<BR></FONT></DIV></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_002E_01BF3ED6.B2B086E0--
- Raw text -