I'm wishing to round up a float variable to two decimal places regardless of what the float is. My current code is shown below:
void MainMethods::convert(float& floatValue, string numericString)
{
floatValue = stof(numericString); //converts string to a float
floatValue = ceil(floatValue * 100.00) / 100.00;
}
Which just converts the string to a float and then after will round up using ceil(). This works fine for when I have either whole numbers, or numbers that go beyond 3 decimals. However when inputting a value of 2 decimals, such as 567.56, the value then returns 567.57 instead. How do I stop this?