Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

values for integer field 1

Status
Not open for further replies.

mpramods

Technical User
Jun 3, 2003
50
US
I need to insert some values into a column defined as INTEGER. When I check the table after the load, I can see the numbers have changed and have been assigned a Negative sign by Teradata.

The conversion is as follows

2150272280 is converted to -2144695016
2151317548 is converted to -2143649748
2154078896 is converted to -2140888400
2155779784 is converted to -2139187512

I know that a Integer field can handle data in the range of -2147483648 to 2147483647 and all my problem numbers have a value more than '2147483647'. Is this the reason that the numbers more than the maximum value for the integer are being converted into a negative number. If so, is there a logic how the numbers above the range are converted into a different number.

Thanks,
Pramod
 
INTEGER is a four bytes signed value.

With a simple operation, you can verify that :
2150272280 + 2144695016 = 4294967296 with is equivalent to 2**(8*4).
Idem with your other values.

To store a value larger than the range of INTEGER, you have to use DECIMAL or FLOAT values.

To convert your negative value to positive UNSIGNED INTEGER value (wich isn't a Teradata Data Type), you have to do the following :
Code:
CAST(2**32 + NEG_VALUE as DECIMAL(10))

Don't omit to CAST...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top