Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Double Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Double Question" Watch "Double Question" New topic
Author

Double Question

Vidya sumanasekara
Greenhorn

Joined: Feb 03, 2011
Posts: 10


Out put:-
1.0 1.5

Why it gives two different output...
help me....
anirudh jagithyala
Ranch Hand

Joined: Dec 07, 2010
Posts: 41
for d1=3/2
int(operation)int is int

int/int=int therefore 3/2=1.5(int)=1
d1=1 i.e., d1=1.0;

but incase of d2=3/2d
int(operation)double=double

int/double=double;;;;double/int=double
therefore 3/2d=3/2.0=1.5(double)=1.5
d2=1.5


Hope it is clear
Vidya sumanasekara
Greenhorn

Joined: Feb 03, 2011
Posts: 10
anirudh jagithyala wrote:

int/double=double;;;;double/int=double
therefore 3/2d=3/2.0=1.5(double)=1.5
d2=1.5


Hope it is clear


Oh....I got it...Thanks. the case is "2d"...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Double Question