--- layout: stdlib-reference --- # interface IInteger *Inherits from:* [IArithmetic](../iarithmetic-01/index.html), [ILogical](../ilogical-01/index.html) ## Description Represents a type that can be used for integer arithmetic operations. Implemented by builtin scalar types: int, uint, int64_t, uint64_t, int8_t, uint8_t, int16_t, uint16_t. Also implemented by vector<T, N> where T is one of the above scalar types. ## Methods * [toInt](toint-2) * [toInt64](toint64-2) * [toUInt](touint-23) * [toUInt64](touint64-23) * [init](init) ## Remarks This interface can be used to define generic functions that work with integer-like types. See example below. ## Example The following code defines a generic function that computes a*b+1, where a, b can be any integer scalar or vector types. ```csharp T compute(T a, T b) { return a * b + T(1); } RWStructuredBuffer outputBuffer; [numthreads(1,1,1)] void test() { int a = 2; int b = 3; outputBuffer[0] = compute(a, b); // result = 2*3 + 1 = 7 int16_t2 a2 = int16_t2(2, 3); int16_t2 b2 = int16_t2(4, 5); // result2 = int16_t2(2*4 + 1, 3*5 + 1) = int16_t2(9, 16) int16_t2 result2 = compute(a2, b2); outputBuffer[1] = result2.x; } ```