Float,double and decimal types

Source: Internet
Author: User

float: floating point, with byte number 4,32bit, Value range -3.4e38~3.4e38 (7 significant digits)

Double: dual precision, with a byte number of 8,64bit numeric range -1.7e308~1.7e308 (15 significant digits)

Decimal: Digital type, 128bit, no loss of precision, commonly used in bank account calculation. (28 significant digits)

float F = 345.98756f;//The result is displayed as 345.9876, showing only 7 significant digits, rounded to the last digit.

The double d=345.975423578631442d;//result is displayed as 345.975423578631, showing only 15 significant digits, rounded to the last one.

Note: The multiplication of float and double, digital overflow will not error, there will be a loss of precision.

The decimal dd=345.545454879.....//can support 28-bit, rounded to the last one.

Note: When working with the decimal type, the value will be an error due to overflow.

Float,double and decimal types

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.