• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Double Question

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Out put:-
1.0 1.5

Why it gives two different output...
help me....
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"...
 
reply
    Bookmark Topic Watch Topic
  • New Topic