kimath: Switch from INT_MAX to std::numeric_limits
This commit is contained in:
parent
bc28287fa7
commit
9292158c76
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <limits.h> // for INT_MAX
|
||||
#include <limits>
|
||||
|
||||
#include <geometry/seg.h> // for SEG
|
||||
#include <geometry/shape.h>
|
||||
|
@ -174,8 +174,8 @@ static VECTOR2I pushoutForce( const SHAPE_CIRCLE& aA, const SEG& aB, int aCleara
|
|||
static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_LINE_CHAIN_BASE& aB,
|
||||
int aClearance, int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV )
|
||||
{
|
||||
int closest_dist = INT_MAX;
|
||||
int closest_mtv_dist = INT_MAX;
|
||||
int closest_dist = std::numeric_limits<int>::max();
|
||||
int closest_mtv_dist = std::numeric_limits<int>::max();
|
||||
VECTOR2I nearest;
|
||||
int closest_mtv_seg = -1;
|
||||
|
||||
|
@ -293,7 +293,7 @@ static inline bool Collide( const SHAPE_LINE_CHAIN_BASE& aA, const SHAPE_LINE_CH
|
|||
aA.TypeName(),
|
||||
aB.TypeName() ) );
|
||||
|
||||
int closest_dist = INT_MAX;
|
||||
int closest_dist = std::numeric_limits<int>::max();
|
||||
VECTOR2I nearest;
|
||||
|
||||
if( aB.IsClosed() && aA.GetPointCount() > 0 && aB.PointInside( aA.GetPoint( 0 ) ) )
|
||||
|
@ -375,7 +375,7 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_LINE_CHAIN_BASE& a
|
|||
aA.TypeName(),
|
||||
aB.TypeName() ) );
|
||||
|
||||
int closest_dist = INT_MAX;
|
||||
int closest_dist = std::numeric_limits<int>::max();
|
||||
VECTOR2I nearest;
|
||||
|
||||
if( aB.IsClosed() && aB.PointInside( aA.Centre() ) )
|
||||
|
@ -529,7 +529,7 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_LINE_CHAIN& aB, int
|
|||
aA.TypeName(),
|
||||
aB.TypeName() ) );
|
||||
|
||||
int closest_dist = INT_MAX;
|
||||
int closest_dist = std::numeric_limits<int>::max();
|
||||
VECTOR2I nearest;
|
||||
|
||||
if( aB.IsClosed() && aB.PointInside( aA.GetP0() ) )
|
||||
|
@ -619,7 +619,7 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_LINE_CHAIN_BASE& aB
|
|||
aA.TypeName(),
|
||||
aB.TypeName() ) );
|
||||
|
||||
int closest_dist = INT_MAX;
|
||||
int closest_dist = std::numeric_limits<int>::max();
|
||||
VECTOR2I nearest;
|
||||
|
||||
if( aB.IsClosed() && aB.PointInside( aA.GetP0() ) )
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <limits.h> // for INT_MAX
|
||||
#include <limits>
|
||||
#include <math.h> // for hypot
|
||||
#include <map>
|
||||
#include <string> // for basic_string
|
||||
|
@ -1884,7 +1884,7 @@ const VECTOR2I SHAPE_LINE_CHAIN::NearestPoint( const VECTOR2I& aP,
|
|||
return { 0, 0 };
|
||||
}
|
||||
|
||||
int min_d = INT_MAX;
|
||||
int min_d = std::numeric_limits<int>::max();
|
||||
int nearest = 0;
|
||||
|
||||
for( int i = 0; i < SegmentCount(); i++ )
|
||||
|
@ -1943,7 +1943,7 @@ const VECTOR2I SHAPE_LINE_CHAIN::NearestPoint( const SEG& aSeg, int& dist ) cons
|
|||
|
||||
int nearest = 0;
|
||||
|
||||
dist = INT_MAX;
|
||||
dist = std::numeric_limits<int>::max();
|
||||
|
||||
for( int i = 0; i < PointCount(); i++ )
|
||||
{
|
||||
|
@ -1962,7 +1962,7 @@ const VECTOR2I SHAPE_LINE_CHAIN::NearestPoint( const SEG& aSeg, int& dist ) cons
|
|||
|
||||
int SHAPE_LINE_CHAIN::NearestSegment( const VECTOR2I& aP ) const
|
||||
{
|
||||
int min_d = INT_MAX;
|
||||
int min_d = std::numeric_limits<int>::max();
|
||||
int nearest = 0;
|
||||
|
||||
for( int i = 0; i < SegmentCount(); i++ )
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <climits>
|
||||
#include <limits>
|
||||
#include <math/util.h>
|
||||
#include <wx/log.h>
|
||||
#include <wx/string.h>
|
||||
|
@ -126,9 +126,9 @@ int64_t rescale( int64_t aNumerator, int64_t aValue, int64_t aDenominator )
|
|||
|
||||
r = c / 2;
|
||||
|
||||
if( b <= INT_MAX && c <= INT_MAX )
|
||||
if( b <= std::numeric_limits<int>::max() && c <= std::numeric_limits<int>::max() )
|
||||
{
|
||||
if( a <= INT_MAX )
|
||||
if( a <= std::numeric_limits<int>::max() )
|
||||
return sign * ( ( a * b + r ) / c );
|
||||
else
|
||||
return sign * ( a / c * b + ( a % c * b + r ) / c);
|
||||
|
|
Loading…
Reference in New Issue