Skip to content
Snippets Groups Projects
Commit 36f72696 authored by Sebastien Ponce's avatar Sebastien Ponce Committed by Marco Clemencic
Browse files

Fixed float comparisons in HepRndmGenerators.cpp

parent ffcf33bd
No related branches found
No related tags found
1 merge request!1490Fixed unsafe floating point comparisons
Pipeline #6365660 passed
...@@ -326,12 +326,6 @@ namespace HepRndm { ...@@ -326,12 +326,6 @@ namespace HepRndm {
double shoot() const override { return m_generator->shoot( m_hepEngine ); } double shoot() const override { return m_generator->shoot( m_hepEngine ); }
}; };
#ifdef __ICC
// disable icc remark #1572: floating-point equality and inequality comparisons are unreliable
// The comparison is meant
# pragma warning( push )
# pragma warning( disable : 1572 )
#endif
// Specialized shoot function // Specialized shoot function
template <> template <>
double Generator<Rndm::GaussianTail>::shoot() const { double Generator<Rndm::GaussianTail>::shoot() const {
...@@ -365,15 +359,11 @@ namespace HepRndm { ...@@ -365,15 +359,11 @@ namespace HepRndm {
do { do {
// v = gsl_rng_uniform (r); // v = gsl_rng_uniform (r);
v = RandFlat::shoot( m_hepEngine ); v = RandFlat::shoot( m_hepEngine );
} while ( v == 0.0 ); } while ( std::abs( v ) < std::numeric_limits<double>::epsilon() * m_specs->cut() );
x = sqrt( s * s - 2 * log( v ) ); x = sqrt( s * s - 2 * log( v ) );
} while ( x * u > s ); } while ( x * u > s );
return x * sigma; return x * sigma;
} }
#ifdef __ICC
// re-enable icc remark #1572
# pragma warning( pop )
#endif
} }
} // namespace HepRndm } // namespace HepRndm
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment