Thread: Integer Usage
View Single Post
  #12 (permalink)  
Old 01-24-2008, 09:54 AM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
Literals
Hello everyone

Quote:
Originally Posted by sandeeprao.techno
You can also use
Code:
System.out.println((a + b + c + d + e) / 5.0);
When I use literals of type double I like to do this:
Code:
System.out.println((double)(a + b + c + d + e) / 5d);
This shows me that the brackets result in a double and the 5 is a double. So no conversions is needed before devision.

Hope this helped.
__________________
If your ship has not come in yet then build a lighthouse.
Reply With Quote