This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Why is this happening?  RSS feed

 
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
 
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
 
Those cherries would go best on cherry cheesecake. Don't put those cherries on this tiny ad:
Download Free Java APIs to Work with Office Files and PDF
htttp://www.e-iceblue.com/free-apis.html
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!