You have to use code like:
if(val==(int)val)
printf("This number is an integer %i \n",(int)val);
else
printf("This number is still a float %f \n",val);
Main Topics
Browse All TopicsHi guys,
Greetings, I have written a small code for displaying max value, min value, and median of the inputed numbers. I am getting .0000 behind all the numbers. I think I am getting these because I declared array as float. But I don't want those ( except where they are required) .0000, they are kind of annoying to eyes.
Please guys can you give me tips to remove those 00000s.
Thank you.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
If that's the kind of distinction you want to make, then you're better off using modf :
http://cplusplus.com/refer
to split up the floating point value in its integer part and fractional part. You can then check whether the fractional part is reasonably close to 0. something like below.
Using the == operator to compare floating point values is not likely to give the expected result.
Business Accounts
Answer for Membership
by: Infinity08Posted on 2009-10-15 at 14:16:11ID: 25584990
You can specify how many digits you want after the decimal point using for example %.2f for 2 digits after the decimal point.