Examveda

Which data type is best suited to store currency values?

A. INT

B. FLOAT

C. DOUBLE

D. DECIMAL

Answer: Option D

Solution (By Examveda Team)

This question asks about the best way to store money in a MySQL database. Let's break down the options:
Option A: INT
INT is for whole numbers. It wouldn't be good for storing money because money often has cents (like $10.50).
Option B: FLOAT
FLOAT is used for numbers with decimals. But it can have problems with precision. This means that sometimes tiny fractions of a cent might be lost, which is bad for financial calculations.
Option C: DOUBLE
DOUBLE is similar to FLOAT, but it can store even bigger and more precise numbers. Still, it might not be ideal for financial data.
Option D: DECIMAL
DECIMAL is the best option for storing money! It's specifically designed for storing numbers with a fixed number of decimal places, so you can be sure that every cent is accounted for.
So the answer is Option D: DECIMAL

This Question Belongs to MySQL >> MySQL Miscellaneous

Join The Discussion

Related Questions on MySQL Miscellaneous