Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Guys!
I need to round numbers with how many decimals i want, using C++ builder 6.
I saw on google, that to do that i need the setprecision(), but i can't show it
on a Memo!
But, when i click on button, shows it: 3,73456001281738
I don't understand..

C++
#include<iostream>
#include<sstream>
#include<iomanip>

void __fastcall TForm1::Button1Click(TObject *Sender)
{

        AnsiString strValue;

        setprecision(2);
        float value = 3.73456;
        strValue = FloatToStr(value);


   Memo1->Lines->Add(" " + strValue);
}

If i miss something, correct me please. I'm new here.
Thanks!!

PS* (sorry for the english, i'm learning, so.. take it easy..)
Posted

use FloatToStrF[^] function
 
Share this answer
 
Comments
Thales Maggi 13-Dec-12 12:25pm    
Thaanks! It help me a lot! I'll make another ask, if you have time to answer again! hehe
You better take a look at boost[^] library. Its with lots of useful mathematical functions.
 
Share this answer
 
Comments
Thales Maggi 13-Dec-12 12:25pm    
Thank you too!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900