Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 600
  • Last Modified:

[noob][c++] enum + float

precision and rounding and maybe other settings for float type needs to be adjusted

is enum what I should use?

I checked c++ in a nutshell by oreilly, but I can't seem to find any thing from it about enum.


how do I do this?
0
Troudeloup
Asked:
Troudeloup
  • 4
  • 3
1 Solution
 
Jaime OlivaresSoftware ArchitectCommented:
could you detail more your problem?
0
 
TroudeloupAuthor Commented:
yeah.


float a;
a = 13000075

cout << a;


it output this


1.30001e+007
0
 
TroudeloupAuthor Commented:
or more precisely,


what is enum and how do I use it?
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Jaime OlivaresSoftware ArchitectCommented:
you need to learn about STL output manipulators:

cout.precision(0);
cout <<   fixed    << a  << endl;

There are lots of manipulators, have a look to:
http://www.cplusplus.com/reference/iostream/manipulators/
0
 
Jaime OlivaresSoftware ArchitectCommented:
I don't figure out how enumerations can help you in this issue.
0
 
TroudeloupAuthor Commented:
are you saying that it's cout that chop off the parts, not the float type itself?
0
 
Jaime OlivaresSoftware ArchitectCommented:
float value remains untouched. It is just a presentation matter.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now