Διαίρεση δεκαδικών
D.A.Glynos
glynos at ath.forthnet.gr
Sat May 11 22:17:01 EEST 2002
allakse oles tis diaireseis tis morfhs (a/b == 10.0)
se ((double) a/b == 10.0)
kai 8a exeis to epi8umhto apotelesma.
;) Mantepse ti typou apotelesma vgazei h diairesh a/b xwris to casting.
prosekse oti stin 3h printf() to swsto einai na typwsei false.
dimitris
On 11 May 2002, drcypher wrote:
> Δε θυμάμαι αν το θέμα έχει ξανατεθεί...
>
> #include <stdio.h>
>
> int main()
> {
> double a, b;
> a = 10.0; b = 1.0;
> printf("(%g/%g == 10.0) == %s\n", a, b, (a/b == 10.0) ? "true" :
> "false");
> printf("(%g/%g == 10.0) == %s\n", 10.0, 1.0, (10.0/1.0 == 10.0) ?
> "true" : "false");
> a = 1.0; b = 0.1;
> printf("(%g/%g == 10.0) == %s\n", a, b, (a/b == 10.0) ? "true" :
> "false");
> printf("(%g/%g == 10.0) == %s\n", 1.0, 0.1, (1.0/0.1 == 10.0) ? "true"
> : "false");
> }
More information about the Linux-greek-users
mailing list