Using system-supplied datatypes  Exact numeric types: decimal numbers

Chapter 6: Using and Creating Datatypes

Exact numeric types: integers

Adaptive Server provides datatypes bigint, int, smallint, tinyint, unsigned bigint, unsigned int, and unsigned smallint to store integers (whole numbers). These types are exact numeric types; they preserve their accuracy during arithmetic operations.

Choose among the integer types based on the expected size of the numbers to be stored. Internal storage size varies by datatype.

Implicit conversion from any integer type to a different integer type is supported only if the value is within the range of the type being converted to.

Unsigned integer datatypes allow you to extend the range of the positive numbers for the existing integer types without increasing the required storage size. That is, the signed versions of these datatypes extend both in the negative direction and the positive direction (for example, from -32 to +32). However, the unsigned versions extend only in the positive direction. Table 6-2 describes the range of the signed and unsigned versions of these datatypes.

Table 6-2: Ranges for signed and unsigned datatypes

Datatype

Range of signed datatypes

Datatype

Range of unsigned datatypes

bigint

Whole numbers between -263 and 263 - 1 (from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807, inclusive

unsigned bigint

Whole numbers between 0 and 18,446,744,073,709,551,615

int

Whole numbers between -231 and 231 - 1 (-2,147,483,648 and 2,147,483,647), inclusive

unsigned int

Whole numbers between 0 and 4,294,967,295

smallint

Whole numbers between -215 and 215 -1 (-32,768 and 32,767), inclusive

unsigned smallint

Whole numbers between 0 and 65535





Copyright © 2005. Sybase Inc. All rights reserved. Exact numeric types: decimal numbers

View this book as PDF