0026668: Eliminate compile warnings obtained by building occt with vc14: conversion...
[occt.git] / src / Standard / Standard_Integer.hxx
CommitLineData
b311480e 1// Copyright (c) 1998-1999 Matra Datavision
a174a3c5 2// Copyright (c) 1999-2013 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
7fd59977 15#ifndef _Standard_Integer_HeaderFile
16#define _Standard_Integer_HeaderFile
17
7fd59977 18#include <Standard_TypeDef.hxx>
2cb44241 19#include <Standard_values.h>
7fd59977 20
21// ===============
22// Inline methods
23// ===============
24
25// ------------------------------------------------------------------
26// Abs : Returns the absolute value of an Integer
27// ------------------------------------------------------------------
ee9e67ed 28inline Standard_Integer Abs (const Standard_Integer Value)
29{
7fd59977 30 return Value >= 0 ? Value : -Value;
31}
32
33// ------------------------------------------------------------------
34// Hascode : Computes a hascoding value for a given Integer
35// ------------------------------------------------------------------
a174a3c5 36inline Standard_Integer HashCode (const Standard_Integer theMe,
37 const Standard_Integer theUpper)
7fd59977 38{
a174a3c5 39 //return (Abs (theMe) % theUpper) + 1;
40 return ((theMe & 0x7fffffff ) % theUpper) + 1;
7fd59977 41}
42
43// ------------------------------------------------------------------
44// IsEqual : Returns Standard_True if two integers are equal
45// ------------------------------------------------------------------
a174a3c5 46inline Standard_Boolean IsEqual (const Standard_Integer theOne,
47 const Standard_Integer theTwo)
48{
49 return theOne == theTwo;
50}
51
ee9e67ed 52// ------------------------------------------------------------------
53// Hascode : Computes a hascoding value for a given long long integer
54// ------------------------------------------------------------------
55inline Standard_Integer HashCode(const long long int theMe,
56 const Standard_Integer theUpper)
57{
58 return ((theMe & 0x7fffffffffffffff) % theUpper) + 1;
59}
60
d44e14e3 61#if (defined(_LP64) || defined(__LP64__) || defined(_WIN64)) || defined(__APPLE__)
a174a3c5 62// ------------------------------------------------------------------
63// Hascode : Computes a hascoding value for a given unsigned integer
64// ------------------------------------------------------------------
65inline Standard_Integer HashCode (const Standard_Utf32Char theMe,
66 const Standard_Integer theUpper)
67{
68 return ((theMe & 0x7fffffff ) % theUpper) + 1;
69}
70
71// ------------------------------------------------------------------
72// IsEqual : Returns Standard_True if two integers are equal
73// ------------------------------------------------------------------
74inline Standard_Boolean IsEqual (const Standard_Utf32Char theOne,
75 const Standard_Utf32Char theTwo)
76{
77 return theOne == theTwo;
78}
79#endif
7fd59977 80
81// ------------------------------------------------------------------
7fd59977 82// IsEven : Returns Standard_True if an integer is even
83// ------------------------------------------------------------------
ee9e67ed 84inline Standard_Boolean IsEven (const Standard_Integer Value)
7fd59977 85{ return Value % 2 == 0; }
86
87
88// ------------------------------------------------------------------
89// IsOdd : Returns Standard_True if an integer is odd
90// ------------------------------------------------------------------
ee9e67ed 91inline Standard_Boolean IsOdd (const Standard_Integer Value)
7fd59977 92{ return Value % 2 == 1; }
93
94// ------------------------------------------------------------------
95// Max : Returns the maximum integer between two integers
96// ------------------------------------------------------------------
97inline Standard_Integer Max (const Standard_Integer Val1,
ee9e67ed 98 const Standard_Integer Val2)
7fd59977 99{
100 return Val1 >= Val2 ? Val1 : Val2;
101}
102
103// ------------------------------------------------------------------
104// Min : Returns the minimum integer between two integers
105// ------------------------------------------------------------------
ee9e67ed 106inline Standard_Integer Min (const Standard_Integer Val1,
107 const Standard_Integer Val2)
7fd59977 108{
109 return Val1 <= Val2 ? Val1 : Val2;
110}
111
112// ------------------------------------------------------------------
113// Modulus : Returns the remainder of division between two integers
114// ------------------------------------------------------------------
ee9e67ed 115inline Standard_Integer Modulus (const Standard_Integer Value,
116 const Standard_Integer Divisor)
7fd59977 117{ return Value % Divisor; }
118
119// ------------------------------------------------------------------
120// Square : Returns the square of an integer
121// ------------------------------------------------------------------
ee9e67ed 122inline Standard_Integer Square(const Standard_Integer Value)
7fd59977 123{ return Value * Value; }
124
125// ------------------------------------------------------------------
126// IntegerFirst : Returns the minimum value of an integer
127// ------------------------------------------------------------------
ee9e67ed 128inline Standard_Integer IntegerFirst()
7fd59977 129{ return INT_MIN; }
130
131// ------------------------------------------------------------------
132// IntegerLast : Returns the maximum value of an integer
133// ------------------------------------------------------------------
ee9e67ed 134inline Standard_Integer IntegerLast()
7fd59977 135{ return INT_MAX; }
136
137// ------------------------------------------------------------------
138// IntegerSize : Returns the size in digits of an integer
139// ------------------------------------------------------------------
ee9e67ed 140inline Standard_Integer IntegerSize()
7fd59977 141{ return BITS(Standard_Integer); }
142
ee9e67ed 143#endif