Detailed explanation of the decimal padding problem of decimal data type in MySQL

Detailed explanation of the decimal padding problem of decimal data type in MySQL

Preface

During the development process, we often use the decimal data type. Because decimal is an accurate data type in MySQL.

The data types in MySQL include: float, double and other imprecise data types and decimal, which are precise data types.

Difference: For float, double and other inexact types, approximate values ​​are stored in the DB.

Decimal stores the exact original value in the form of a string.

Introduction to decimal:

decimal(a,b)

Where: a specifies the maximum number of decimal digits that can be stored to the left and right of the decimal point, with a maximum precision of 38. b specifies the maximum number of decimal digits that can be stored to the right of the decimal point. The number of decimal places must be a value between 0 and a. The default number of decimal places is 0.

Note: DECIMAL data types are used in calculations that require very high precision. These types allow the precision and counting method of the values ​​to be specified as selection parameters. Precision here refers to the total number of significant digits stored for the value, while the count method indicates the number of digits after the decimal point.

question

When the length of the decimal type is less than 14, when inserting data into the decimal type field, the invalid decimal 0 will be automatically removed. Only when the length of the decimal type is greater than or equal to 14 digits, the invalid 0 in the decimal place will be retained and the decimal places will be automatically filled.

insert image description here

insert image description here

Notice

When the page is displayed, the data also needs to be formatted (decimal places), otherwise invalid 0s will be removed.

This is the end of this article about the detailed explanation of the decimal padding problem of the decimal data type in MySQL. For more relevant MySQL decimal padding content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • A brief introduction to the usage of decimal type in MySQL
  • The difference between Decimal type and Float Double in MySQL (detailed explanation)
  • Detailed explanation of the meaning of N and M in the MySQL data type DECIMAL(N,M)
  • Method to convert scientific notation numeric string to decimal type
  • Database data type float to C# type decimal, float data type conversion is invalid
  • Detailed explanation of the usage of DECIMAL in MySQL data type
  • Implementation of mysql decimal data type conversion
  • Detailed explanation of the usage of MySQL data type DECIMAL
  • In-depth explanation of the use and implementation of the Decimal type in the database

<<:  Windows Server 2016 Quick Start Guide to Deploy Remote Desktop Services

>>:  Two ways to add a mask effect to the background image using background-color through CSS

Recommend

Introduction to CSS3 color value RGBA and gradient color usage

Before CSS3, gradient images could only be used a...

Difference between var and let in JavaScript

Table of contents 1. Scopes are expressed in diff...

Take you to understand the event scheduler EVENT in MySQL

The event scheduler in MySQL, EVENT, is also call...

4 ways to implement routing transition effects in Vue

Vue router transitions are a quick and easy way t...

Use neat HTML markup to build your pages

The Internet is an organism that is constantly ev...

MySQL 8.0.13 installation and configuration method graphic tutorial under win10

I would like to share the installation and config...

Several important MySQL variables

There are many MySQL variables, some of which are...

How to install Linux online software gcc online

Linux online installation related commands: yum i...

MySQL transaction concepts and usage in-depth explanation

Table of contents The concept of affairs The stat...

Detailed explanation of several storage methods of docker containers

Table of contents Written in front Several storag...

Simple example of adding and removing HTML nodes

Simple example of adding and removing HTML nodes ...

Linux file and user management practice

1. Display the files or directories in the /etc d...