26
Sep

I am looking at somebody elses code, and they have:

double d = 0.0D

Whats the huge D for at the end?

as far as I have the ability to tell: double d = 0.0; does the same thing.

simple 10pts


Answer:
You're right.

The “D” turns a number into a “double”. But 0.0 is already a double. So the “D” is unnecessary.

The “D” is supposed to be used for quick conversions to double, such as changing an int to a double, like this

double d = 0D;

Java also has “F” and “L” to convert numbers to “float” and “long”.

Book Mark it-> del.icio.us | Reddit | Slashdot | Digg | Facebook | Technorati | Google | StumbleUpon | Window Live | Tailrank | Furl | Netscape | Yahoo | BlinkList

This entry was posted on Friday, September 26th, 2008 at 3:11 pm and is filed under Programming. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or TrackBack URI from your own site.

Leave a reply

Name (*)
Mail (*)
URI
Comment