very basic!

#include <iostream.h>
#include <iomanip.h>

main()
{
    float myFloat;

    cin >> myFloat;
    cout << setiosflags(ios::fixed) << setprecision(2) << myFloat;
}

entering 3,5 gives the result 3,00 in an easywinproj! Why?

Thanks!
sa9813Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nietodCommented:
Try using a "." for a decimal point, not a ",".   I beleive there are options for changing this,but I'm not sure fo the details.
0
sa9813Author Commented:
I live in sweden, the ',' is standard over here, that's not the problem! But thanx anyway!
0
joshaubryCommented:
you need to set up cout for setprecision and setiosflags does not do it

try this...

#include <iostream.h>
#include <iomanip.h>

void main()
{
   float myFloat;
   
   cout.setf(ios::fixed, ios::floatfield);   // Set up floating point
   cout.setf(ios::showpoint);               //        output format.

   cin >> myFloat;
   cout << setprecision(2) << myFloat;
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

sa9813Author Commented:
Maybe you are right nietod, but when I try your proposed awnser I get a float overload err message!
0
joshaubryCommented:
yes, use the code i gave you with a '.' instead of a ','
0
sa9813Author Commented:
Very strange, that does not fix it! If I write the float with ',' there is no errormessage, but the result is not correct, the output is 3.00 . But if I write the float with '.' there is a errormessage, 'Overflow'.
0
joshaubryCommented:
is your compiler set up to understand '.' as the decimal point or ','?

i'm in the US and the code i gave you works for '.'
0
nietodCommented:
sa9813, you may need to use setlocal() to set the RTL's localation setting, which controls this and much more.  I don't know details about this though.
0
nietodCommented:
I found it.  For sweden, use

setlocale(LC_NUMERIC,"sweden");


there are many other options you may also wish to set.  The docus for setlocale() will list these.
0
sa9813Author Commented:
Thank u for your help even though I still have problem, I guess I will figure out sooner or later...I'm just playing around. Thank u nietod, I do not know how to give u points for your help!?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.