Search
 
SCRIPT & CODE EXAMPLE
 

CPP

set precision on floating numbers

#include <iostream>
#include <iomanip>
#include <vector>

using std::cout; using std::endl;
using std::vector; using std::fixed;
using std::setprecision;

int main() {
    vector<double> d_vec = {123.231, 2.2343, 0.012,
                            26.9491092019, 113, 0.000000234};

    for (auto &i : d_vec) {
        cout << i << " | ";
    }
    cout << endl;

    for (auto &i : d_vec) {
        cout << setprecision(3) << i << " | ";
    }
    cout << endl;

    return EXIT_SUCCESS;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: qt_invok 
Cpp :: how to find the sum of elements in a stack in cpp 
Cpp :: c++ start process and get output 
Cpp :: how to check private messages on reddit 
Cpp :: cannot access base class members 
Cpp :: GCD(x, yz) 
Cpp :: 28+152+28+38+114 
Cpp :: copying a file to an array and sorting 
Cpp :: can map return a value to a variable in c++ 
Cpp :: export gcc g++ 
Cpp :: how to adjust and delete memory in c, c++ 
Cpp :: initialize many variablles c++ 
Cpp :: operazioni aritmetiche c++ 
Cpp :: all usefull stls in cpp imports 
Cpp :: c++ to c converter online 
Cpp :: composition namespaces c++ 
Cpp :: std::random_device 
Cpp :: split the array there is an array val of n integers . A good subarray is defined as 
Cpp :: what is imposter syndrome 
Cpp :: librerias matematicas en c++ para numeros aleatorios 
Cpp :: sin trigonometric function 
Cpp :: ++i v.s i++ 
Cpp :: c++ multiplication table rows and columns 
Cpp :: dijkstra algorithm in c++ geeksforgeeks 
Cpp :: nlohmann json, writing to json file 
Cpp :: passing a 2d array cpp 
Cpp :: cin in c++ 
Cpp :: inpout in Array c++ 
Cpp :: c++ filesystem remove file 
Cpp :: do while loop c++ 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =