• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why is this happening?  RSS feed

 
Shrinath M Aithal
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


removed parts I've felt unnecessary.. If anyone wants, I can post it..

My problem is :

If I keep on increasing/ changing the value of good and total, like say 1/1, 2/2... it goes properly..
If bad value changes, like
good = 4, bad=1, total=5,
then the result of (good/total) should be 0.8
It is showing zero!!

what am I missing here ??
 
Shrinath M Aithal
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
never mind
got it..
it tends to save the intermediate result in "int"

i.e I changed the line :
to


Now I feel so silly, someone tell me how do i delete this message
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to declare good bad in double or float , as you have fefined it as integer its losing its precision values
check it out
 
Shrinath M Aithal
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ravindra patil wrote:You need to declare good bad in double or float , as you have fefined it as integer its losing its precision values
check it out


Thank you Mr. Ravindra
I was over this from yesterday night, and now after a minute since posting it, I realized my mistake
How silly it looks
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep it happens ... :0
we learn a lot from mistakes even though its small

cheers
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!