POV
POV

Reputation: 12025

Out of range decimal type Mysql?

I need to store int and floating values numbers in field.

I use this type for field: decimal(5,4).

When I tried to store number 10 I got an error: Out of range decimal.

Why, if decimal(5,4) allows 5 position before dot and 4 positions after?

Upvotes: 2

Views: 5052

Answers (2)

Gordon Linoff
Gordon Linoff

Reputation: 1271241

You are misunderstanding. decimal(5, 4) has 5 total digits of precision with 4 digits of scale after the decimal place. Hence, one is before.

You seem to want decimal(9, 4).

Upvotes: 4

Kanami
Kanami

Reputation: 66

In the decimal(x, y) format, the x stands for the total number of digits, and y for the number of digits after the decimal place (. or ,). If assuming you want to store numbers up to 4 digits long (1000) with a precision of 2 (0.01) you'd need to use decimal(6, 2).

Upvotes: 4

Related Questions