fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7. float minVal = pow(2,-149); // set to smallest float possible
  8.  
  9. float nextCheck = ((float)((minVal/2.0f))); // divide by two
  10. bool isZero = (static_cast<float>(minVal/2.0f) == 0.0f); // this thing evaluates to false when it really shouldn't...!?
  11. bool isZero2 = (nextCheck == 0.0f); // this evaluates to true
  12.  
  13. cout << nextCheck << " " << isZero << " " << isZero2 << endl;
  14. // this outputs 0 0 1
  15.  
  16. return 0;
  17.  
  18. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
0 1 1