• 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

A great doubt in Widening Numeric Conversions

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Guys,
I follow the “A Programmers guide to Java Certification” by Khalid Mughal.
It was stated that the Widening conversion takes place in the trasitive order given below

byte -> short-> int -> long -> float -> double
char -> int -> long -> float -> double

From the above stated rule, I presume that the following is a widening conversion.

long bigInteger = 987654321123456789L;
float realNo = bigInteger;

I had No doubt till this point.

Guys, Now just stop here for a while and I would ask you to roll back your memories to the size of data types.
The size of long is 64 bits and the float is just 32 bits.

I don’t think that the “long” number would be able to fit comfortably within a float variable which is obviously less than the size of long datatype.

How can this be regarded as a widening conversion?

I don’t know, if I am asking so silly. Anyway a doubt is a doubt. Somebody please throw light on this
[ September 02, 2005: Message edited by: Kalyana Sundaram ]
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kalyana

Float is supporting Floating point representation i.e some part of memory assigned to float is used to store mantisaa and other for exponent.Taking an example not according to exact represntation but would give u an idea:

2500 = 0.25 * 10 power 4
i will store it as 25 in one part and 4 in some other part

so using 32 bit no we can store a wide range of no.
But we do have a problem here i.e Loss of Precesion ..
Yaa I agree loss of precision is there because mantisaa part is of fixed size.

I think this would have cleared ur doubt ........
else i am always there to help u out we can discuss more

Regards
Abhishek
 
Kalyana Sundaram
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your answer.
Well, I do think that there are much behind this.
However this enough for just having an idea.

Come on, Lets explore JAVA !!!
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Come on, Lets explore JAVA !!!
--------------------
Only those who will risk going too far can possibly find out how far one can go !!!




Kalyana & Abhishek... I would love to be part of exploring java to maximum extend. But stuck with Microsoft and involved in analysis and design work. even delayed my exam.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic