Vous n'avez pas besoin de Boost du tout, juste la bibliothèque C incluse dans la bibliothèque C++. Plus précisément, vous devez inclure l'en-tête de cmath:
ronde un certain nombre: Ceil(): http://www.cplusplus.com/reference/clibrary/cmath/ceil/
Arrondir un numéro: étage(): http://www.cplusplus.com/reference/clibrary/cmath/floor/
Vous pouvez écrire votre propre fonction tour, puis :
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <utility>
double roundFloat(double x)
{
double base = floor(x);
if (x > (base + 0.5))
return ceil(x);
else return base;
}
int main()
{
std::string strInput;
double input;
printf("Type a number: ");
std::getline(std::cin, strInput);
input = std::atof(strInput.c_str());
printf("\nRounded value is: %7.2f\n", roundFloat(input));
return EXIT_SUCCESS;
}
Qu'est-ce que "le nombre le plus proche"? – adf88