• 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

Is Float more Specific than Double

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi :
I was doing one of the practice exams and come across conversion.

Just wondering, is float more specific than double?

i think float is 32 bits and double is 64
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
float and double are primitive types, not class instance types. So what do you mean by "more specific"?

If you mean Float and Double as wrapper classes then, the two classes are distinct subclasses of class Number.
[ November 17, 2006: Message edited by: Barry Gaunt ]
 
kay lin
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was looking at the answers at one of the pracitce questions
Answers
Take a look at answer No.2,
I was confused as to what he meant by float is more "specific" than double..
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kay,

You're right that float is 32 bits and double is 64 bits. So from a point of view of widening the least wide parameter that matches should be used. O can understand that int which is 32 bits would prefer float over double. What surprises me is that long which is 64 bits would fit in a float. In fact I started a new topic regarding this.

As far as which is more specific, the explanation doesn't actually say that a long is more specific than a double. It says the Method that uses a long is more specific than the Method that uses a double. I guess the word specific has a specific meaning when it comes to OOP with regards to classes. I don't know if it's really proper to say one Method is more specific than another. In a sense I suppose you could say a float IS-A double because any float will fit in a double, but that's stretching it I suppose. It's just using IS-A in terms of a subset which is part of the meaning in OOP but doesn't taken into account things like polymorphism.

Oh well, I guess different people have different ideas about what is OOP - just look at C++
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic