Hello!
I implement the project on Qt. I am trying to deduce a fraction whose denominator is not a power of two (19 decimal places). For example, 1/5 = 0, 0000000000000000111.
It is clear that such a view is a feature of the representation of floating point numbers in C ++. But how to display the result available to the user (1/5 = 0.2)? The output format is desirable not to change.
I use the following method to display the number.
QString MainWindow::numberFormat(const double &number) { QString str = QLocale::system().toString(number, 'f', 21); return str.remove(QRegExp(",?0+$")); } I ask for your help, thank you in advance.