Plenty of languages are going to get upset if you add 2 billion to 2 billion.
9999999999999999.0 – 9999999999999998.0
21–30 of 274 posts
Re: 9999999999999999.0 – 9999999999999998.0
#22Google calculator gives answer 0 where as duckduckgo calculator answers with 2. xD
Re: 9999999999999999.0 – 9999999999999998.0
#23Re: 9999999999999999.0 – 9999999999999998.0
#24Re: 9999999999999999.0 – 9999999999999998.0
#252 with 64 bit floats, 0 with 32 bit floats.
I could understand 0, but how does it get 2?
Re: 9999999999999999.0 – 9999999999999998.0
#26Re: 9999999999999999.0 – 9999999999999998.0
#27Re: 9999999999999999.0 – 9999999999999998.0
#28 #include
#include
#include
using fl50 = boost::multiprecision::cpp_dec_float_50;
int main() {
auto a = boost::lexical_cast("9999999999999999.7");
auto b = boost::lexical_cast("9999999999999998.5");
std::cout
works int main() {
fl50 a = 9999999999999999.7;
fl50 b = 9999999999999998.5;
std::cout
doesn't, even if you change fl50 out for a quad precision binary float type.Re: 9999999999999999.0 – 9999999999999998.0
#29A useful website for these that I ran across recently: https://float.exposed/ For example, entering 9999999999999999.0 into "double" gives https://float.exposed/0x4341c37937e08000 and entering 9999999999999998.0 gives https://float.exposed/0x4341c37937e07fff My wishlist for such a page would contain two additional features: 1. Allow entering expressions like "a OP b == c", so that one can enter "0.1 + 0.2 == 0.3" or…
Re: 9999999999999999.0 – 9999999999999998.0
#30Are there any mainstream languages that consider a decimal number to be a primitive type? I feel like floating point numbers are far less meaningful in every day programs. Even 2d graphics would be easier with decimal numbers. Unless you're using numbers that scale from very small to very large, like 3d games or scientific calculations, you don't actually want to use floating point.