Formatting Double to String? [duplicate]

Understand the Double Data type – it is an approximation of amount and scale.

The Following assignment:

double d = 2.00000000000f;

will generate a value of 1.9999999 at times when printed. What you are seeing here is magnification of that. Double Data types also have a maximum (implementation-dependant) of how many places of significance they can support (upto 15 generally) – which is why the last 6 digits are all zeros (0)

For your particular solution, if you don’t require Floating-point Data, stick to Integer.

Browse More Popular Posts

Leave a Comment