Quastion for beginners

Hallo i am a beginner in c++ and my prof asked us a quastion . so why the result below is (inf). so why it is (inf) and what does inf mean in c++

thx



#include <iostream>

using namespace std;
int main()
{
float x = 1.0e20f,
y = 1.0f,
z = 1.0e20f,
u = 1.0f;
cout << "the result is: " << y /((x+y-z)*u) << endl;
return 0;
}

run:
the result is: inf


The question is about floating point arithmetic.
To put shortly, it is weird. For more words, read: https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
Topic archived. No new replies allowed.