avoid rounding error (floating specifically) c++

前端 未结 6 1569
耶瑟儿~
耶瑟儿~ 2021-02-04 12:54

http://www.learncpp.com/cpp-tutorial/25-floating-point-numbers/ I have been about this lately to review C++.

In general computing class professors tend not to cover thes

6条回答
  •  终归单人心
    2021-02-04 13:26

    Short version - you can't really avoid rounding and other representation errors when you're trying to represent base 10 numbers in base 2 (ie, using a float or a double to represent a decimal number). You pretty much either have to work out how many significant digits you actually have or you have to switch to a (slower) arbitrary precision library.

提交回复
热议问题