Difference between Numeric and Float

  • Hi all,

    I am getting error message while trying to insert Float datatype values into Numeric datatype column. How can we avoid this ?

    Also, please tell me what is the difference between float and numeric datatypes.

    Thanks,

    Ezhilan

  • Numeric (also called Decimal) has a defined precision and scale. Float just uses defaults for that.

    You can end up with overflow errors because of this.

    For example, if you define a column/variable as Numeric(10,8), you are defining it with a total of 10 digits, and 8 of them are the right of the decimal place. If you try to insert any number >= 100 into this, it will give an error. A Float data type can handle those numbers quite easily, so that conversion will give you errors. (It can go the other way as well, if you have a float with 10 digits to the right of the decimal, and put them in a numeric with only 8, it will cut off the last two digits. Won't give an error, but will drop the precision.)

    That's probably what's happening to you. Many people define numeric (decimal) data types for the largest precision they think will happen, and don't realize they are reducing the number of allowed digits to the left of the decimal.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply