![]() |
Home | -Libraries | +Libraries | People | FAQ | More | @@ -31,7 +31,7 @@
| - |
![]() |
Home | -Libraries | +Libraries | People | FAQ | More | @@ -29,7 +29,7 @@
| - |
![]() |
Home | -Libraries | +Libraries | People | FAQ | More |
A type is Numeric if it has the properties of a number.
+More specifically, a type T is Numeric if there exists
+ specialization of std::numeric_limits<T>. See the
+ documentation for standard library class numeric_limits. The standard
+ library includes such specializations for all the primitive numeric types.
+ Note that this concept is distinct from the C++ standard library type
+ traits is_integral and is_arithmetic. These
+ latter fullfill the requirement of the concept Numeric. But there are
+ types T which fullfill this concept for which
+ is_arithmetic<T>::value == false. For example see
+ safe_signed_integer<int>.
Table 1. Notation
+T, U, V |
+A type that is a model of the Numeric | +
t, u, v |
+An object of type modeling Numeric | +
Table 2. Associated Types
+std::numeric_limits<T> |
+The numeric_limits class template provides a C++ program + with information about various properties of the implementation’s + representation of the arithmetic types. See C++ standard + 18.3.2.2. | +
In addition to the expressions defined in Assignable the + following expressions must be valid.
+Any operations which result in integers which cannot be represented + as some Numeric type will throw an exception.
+Table 3. General
+| Expression | +Return Value | +
|---|---|
std::numeric_limits<T>.is_bounded
+ |
+true | +
std::numeric_limits<T>.is_integer |
+true | +
std::numeric_limits<T>.is_specialized
+ |
+true | +
Table 4. Unary Operators
+| Expression | +Return Type | +Semantics | +
|---|---|---|
-t |
+T | +Invert sign | +
+t |
+T | +unary plus - a no op | +
t-- |
+T | +post decrement | +
t++ |
+T | +post increment | +
--t |
+T | +predecrement | +
++t |
+T | +preincrement | +
~ |
+T | +complement | +
Table 5. Binary Operators
+| Expression | +Return Type | +Semantics | +
|---|---|---|
t - u |
+V | +subtract u from t | +
t + u |
+V | +add u to t | +
t * u |
+V | +multiply t by u | +
t / u |
+T | +divide t by u | +
t % u |
+T | +t modulus u | +
t << u |
+T | +shift t left u bits | +
t >> u |
+T | +shift t right by ubits | +
t < u |
+bool | +true if t less than u, false otherwise | +
t <= u |
+bool | +true if t less than or equal to u, false otherwise | +
t > u |
+bool | +true if t greater than u, false otherwise | +
t >= u |
+bool | +true if t greathan or equal to u, false otherwise | +
t == u |
+bool | +true if t equal to u, false otherwise | +
t != u |
+bool | +true if t not equal to u, false otherwise | +
t & u |
+V | +and of t and u padded out max # bits in t, u | +
t | u |
+V | +or of t and u padded out max # bits in t, u | +
t ^ u |
+V | +exclusive or of t and u padded out max # bits in t, + u | +
t = u |
+T |
+assign value of u to t | +
t += u |
+T |
+add u to t and assign to t | +
t -= u |
+T |
+subtract u from t and assign to t | +
t *= u |
+T |
+multiply t by u and assign to t | +
t /= u |
+T |
+divide t by u and assign to t | +
t &= u |
+T |
+and t with u and assign to t | +
t <<= u |
+T | +left shift the value of t by u bits | +
t >>= u |
+T | +right shift the value of t by u bits | +
t &= u |
+T | +and the value of t with u and assign to t | +
t |= u |
+T | +or the value of t with u and assign to t | +
t ^= u |
+T | +exclusive or the value of t with u and assign to t | +
| - |