What is the suitable data type for price. Where the output will be 24.00 programming for C++. thank you?

Home » Programming & Design » What is the suitable data type for price. Where the output will be 24.00 programming for C++. thank you?
Programming & Design No Comments

Other answer:

Tamilarasi:
Depends what you will do with it
if you are doing any large numbers or calculations…

http://stackoverflow.com/questions/23867…
a double has 2x the precision of float[1].
In general a double has 15 to 16 decimal digits of precision, while float only has 7.

So there is great safety and advantage in using Double

Software:
Price doesn't need too many digits. Both float and double are fine.
husoski:
The type should normally be double.

Another possibility is float, but on most systems the float type is too limited in precision for the performance and space savings.

roger:
actually the best is BCD
to avoid rounding errors the next best is int and keep track of pennies
convert to dollars when printing the amount…
Marcus Xavier:
https://www.youtube.com/watch?v=JcUz-YGY…

Source (s):
You Tube,..

LEAVE A COMMENT