I'm trying to control the number of Digits i add in a String , but I couldn't control it since i am printing an Array of Strings .
float loads[n] = { 1,2,3,0.05,1,2,3,0.5,1,2,3,3,1,2 };
string print[nBits] = { "" };
int n=14;
int BB;
.
.
.
void main(){
for (int j = 0; j < nBits; ++j)// 2^n
{
for (int i = 0; i < n; ++i) // n
{
BB = arr[j][i];
R = loads[i];
if (BB == 1) {
print[j]+="" +std::to_string(loads[i])+"//";
}
}
}
But i eventually get an Array of strings that Looks like this :
0.050000//3.000000//...
Is there any way to control the Precision of the floating number before adding it to the String ?
(so i can have a resulting string control a fixed number of Digits instead)
0.05//3.00// ...