Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Possible Duplicate:
Most effective way for float and double comparison Most effective way for float and double comparison
strange output in comparison of float with float literal strange output in comparison of float with float literal

int main() 
{
 float a = 0.8;
 if (a == 0.8)
 printf("x\n");
 else 
 printf("y\n");
 return 0;
}

Though a is equal to 0.8, it outputs y.

Possible Duplicate:
Most effective way for float and double comparison
strange output in comparison of float with float literal

int main() 
{
 float a = 0.8;
 if (a == 0.8)
 printf("x\n");
 else 
 printf("y\n");
 return 0;
}

Though a is equal to 0.8, it outputs y.

Possible Duplicate:
Most effective way for float and double comparison
strange output in comparison of float with float literal

int main() 
{
 float a = 0.8;
 if (a == 0.8)
 printf("x\n");
 else 
 printf("y\n");
 return 0;
}

Though a is equal to 0.8, it outputs y.

insert duplicate link
Source Link

Possible Duplicate:
Most effective way for float and double comparison
strange output in comparison of float with float literal

int main() 
{
 float a = 0.8;
 if (a == 0.8)
 printf("x\n");
 else 
 printf("y\n");
 return 0;
}

Though a is equal to 0.8, it outputs y.

int main() 
{
 float a = 0.8;
 if (a == 0.8)
 printf("x\n");
 else 
 printf("y\n");
 return 0;
}

Though a is equal to 0.8, it outputs y.

Possible Duplicate:
Most effective way for float and double comparison
strange output in comparison of float with float literal

int main() 
{
 float a = 0.8;
 if (a == 0.8)
 printf("x\n");
 else 
 printf("y\n");
 return 0;
}

Though a is equal to 0.8, it outputs y.

formatted code ..
Source Link
Levon
  • 144.1k
  • 35
  • 205
  • 194
int main() 
{
float a =0= 0.8;
if (a==0a == 0.8)
printf("x""x\n");
else 
printf("y""y\n");
return 0;
}

Though a is equal to 0.8, it outputs y.

int main() 
{
float a =0.8;
if (a==0.8)
printf("x");
else 
printf("y");
return 0;
}

Though a is equal to 0.8, it outputs y.

int main() 
{
float a = 0.8;
if (a == 0.8)
printf("x\n");
else 
printf("y\n");
return 0;
}

Though a is equal to 0.8, it outputs y.

Source Link
user1593308
  • 571
  • 1
  • 4
  • 5
Loading
lang-c

AltStyle によって変換されたページ (->オリジナル) /