The story behind money float decimal

Source: Internet
Author: User

In the database, what fields are generally used for the amount type, and money is used in actual use. Why is it so useful? Why not use float or decimal?

So we need to talk about the story behind them.

The decimal point of money is four digits, and it will be rounded off with a very small fraction after four digits, so it is suitable for the amount

High decimal precision, but small value range, better running speed than float, easier data processing than float, preferred use, suitable for finance, statistics

Float is an approximate value, but the data range is large. If the number is too large, you can only use this value to avoid using =,Because10.000000887788. the decimal point is a random number. 

 

Corresponding to money in C #, decimal uses decimal, float uses double

 

Execute the following SQL statement to find the value of the auto-increment column corresponding to the newly inserted record. The key is @ identity.

Insert into tbldemo values ('test') Select @ identity 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.