CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2001
    Posts
    872

    FLOAT vs NUMERIC for financial transaction

    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

  2. #2
    Join Date
    Feb 2005
    Location
    Denmark
    Posts
    742

    Re: FLOAT vs NUMERIC for financial transaction

    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).

  3. #3
    Join Date
    Jun 2006
    Posts
    437

    Re: FLOAT vs NUMERIC for financial transaction

    Hi all.

    M$SQL provides "money", a specific data type for monetary data values.
    In my opinion it's the best choice.

  4. #4
    Join Date
    Feb 2001
    Posts
    872

    Re: FLOAT vs NUMERIC for financial transaction

    Thanks guys, my preference is NUMERIC because NUMERIC is compatible with Mysql, Oracle, and MSSQL

  5. #5
    Join Date
    Feb 2005
    Location
    Denmark
    Posts
    742

    Re: FLOAT vs NUMERIC for financial transaction

    Quote Originally Posted by THY02K View Post
    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.

  6. #6
    Join Date
    May 2009
    Posts
    23

    Re: FLOAT vs NUMERIC for financial transaction

    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).
    Last edited by binyo66; June 30th, 2009 at 02:50 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured