I’m testing a script using the floor() function on tutorialspoint’s codingground compiler. I start with this simple script:
#include <iostream>
#include <cmath>
using namespace std;
/* Including std namespace since I am not including any other namespaces. */
int main() {
double var1 = 3.393, var2;
cout << var1 << “ “ << var2;
return 0;
}
Result: 3.393 0.
However, when I add floor()
to var1, var2 changes to 6.95329e-310.
Is there a reason for this, either that it is specific to the compiler or I’m doing something wrong?
Resource: http://tpcg.io/SkgxtNCa