Click to See Complete Forum and Search --> : FLOAT vs NUMERIC for financial transaction
THY02K
June 28th, 2009, 09:23 PM
hello
Do you use FLOAT or NUMERIC for financial transaction? If NUMERIC, what precision? For M$SQL, looks like float offers more digits.
Thanks
http://doc.ddart.net/mssql/sql70/da-db_1.htm
Alsvha
June 29th, 2009, 02:49 AM
Use Decimal due to accuracy.
And the precision is then decided by your requirements. Most of the time 2-4 seems to be the norm (I mostly use 4).
davide++
June 29th, 2009, 03:35 AM
Hi all.
M$SQL provides "money", a specific data type for monetary data values.
In my opinion it's the best choice.
THY02K
June 29th, 2009, 03:38 AM
Thanks guys, my preference is NUMERIC because NUMERIC is compatible with Mysql, Oracle, and MSSQL
Alsvha
June 29th, 2009, 05:10 AM
Thanks guys, my preference is NUMERIC because NUMERIC is compatible with Mysql, Oracle, and MSSQL
Numeric is the same as a decimal. Just another keyword.
binyo66
June 30th, 2009, 03:48 AM
AFAIK, Numeric can be as big and as precise as u want it. In oracle (I think ODBC standard too) numeric can be 20.8. But float or double is 8 bytes. But I always numeric. There is in my constant (I forgot the source) I put some comment below (which I think I copied either from MS or Oracle header).
SQL_CHARSQL_VARCHARSQL_LONGVARCHAR The defined length of the column. For example, the length of a column defined as CHAR(10) is 10.
SQL_LONGVARCHAR The maximum length of the column.
SQL_DECIMALSQL_NUMERIC The maximum number of digits plus two. Since these data types are returned as character strings, characters are needed for the digits, a sign, and a decimal point. For example, the length of a column defined as NUMERIC(10,3) is 12.
SQL_SMALLINT 2 (two bytes).
SQL_INTEGER 4 (four bytes).
SQL_BIGINT 20 (since this data type is returned as a character string, characters are needed for 19 digits and a sign).
SQL_REAL 4 (four bytes).
SQL_FLOAT 8 (eight bytes).
SQL_DOUBLE 8 (eight bytes).
SQL_BINARYSQL_VARBINARY The defined length of the column. For example, the length of a column defined as BINARY(10) is 10.
SQL_LONGVARBINARY The maximum length of the column.
SQL_DATESQL_TIME 6 (the size of the DATE_STRUCT or TIME_STRUCT structure).
SQL_TIMESTAMP 16 (the size of the TIMESTAMP_STRUCT structure).
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.