Peter Bushnell
Peter Bushnell

Reputation: 928

MySQL Store large number with many decimal places

I'm somewhat confused on defining the correct definition for a float table column. This is required to create a database table to store large numbers which have up to eight decimal places. I need to be able to store anywhere from and between the following two.

0.00000001 - 10000000

Would that be defined as float(16) as the argument is the maximum number of digits that need to be displayed. Perhaps I have misunderstood the column definition entirely.

Upvotes: 1

Views: 1573

Answers (1)

Lukasz Szozda
Lukasz Szozda

Reputation: 175606

FLOAT is approximate datatype and I would not recommend it to use for storing exact values.

For storing exact numbers you should use DECIMAL datatype:

CREATE TABLE tab(col DECIMAL(20,10));

Should be more than sufficent for your needs.

Upvotes: 1

Related Questions