• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Double Question

 
Vidya sumanasekara
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Out put:-
1.0 1.5

Why it gives two different output...
help me....
 
anirudh jagithyala
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic