Book Image

Building a Web Application with PHP and MariaDB: A Reference Guide

By : Sai S Sriparasa
Book Image

Building a Web Application with PHP and MariaDB: A Reference Guide

By: Sai S Sriparasa

Overview of this book

Table of Contents (17 chapters)
Building a Web Application with PHP and MariaDB: A Reference Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Number datatypes


Let us now look at the following main number datatypes:

Datatype

Explanation

Comments

tinyint

This stores integer values.

-128 to 127, Signed

0 to 255, Unsigned

Smallint

This stores integer values.

-32768 to 32767, Signed

0 to 65535, Unsigned

Mediumint

This stores integer values.

-8388608 to 8388607, Signed

0 – 16777215, Unsigned

int(l)

This stores integer values and takes the size of the number.

-2147483648 to 2147483647, Signed

0 – 4294967295, Unsigned

Bigint

This stores integer values.

-9223372036854775808 to 9223372036854775807, Signed

0 to 18446744073709551615, Unsigned

Float(l,d)

This stores floating point numbers and allows us to define the display length (l) and the number of digits after the decimal point (d). The default values for l, d are 10 and 2, respectively.

This uses 4-byte single precision and can display from 0 to 23 digits after the decimal.

Double(l,d)

This is similar to FLOAT, and uses 8-byte double precision. The default values for l, d are 16 and 4, respectively.

The DOUBLE datatype can display from 24 to 53 results. Both the FLOAT and DOUBLE datatypes are commonly used for storing the results from scientific calculations.

decimal(l,d)

This stores the exact numeric data values and allows us to define the display length (l) and the number of digits after decimal point (d).

This is used for precision mathematics that deals with extremely accurate results. The DECIMAL datatype is commonly used to store monetary data.