fork download
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. int CountValuesBetween( float start, float end )
  7. {
  8. int num = 0;
  9. for( ; start < end; start = nextafter( start, end ) ) {
  10. ++num;
  11. }
  12. return num;
  13. }
  14.  
  15. int main() {
  16. cout << "Between 500 000 and 500 001 -> " << CountValuesBetween( 500000.f, 500001.f ) << "\n";
  17. cout << "Between 600 000 and 600 001 -> " << CountValuesBetween( 600000.f, 600001.f ) << "\n";
  18. return 0;
  19. }
Success #stdin #stdout 0s 4536KB
stdin
Standard input is empty
stdout
Between 500 000 and 500 001 -> 32
Between 600 000 and 600 001 -> 16