This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.

link with long==>float class myclass{ float i;//float have 32 bits. long j;//long have 64 bits. void method(){ j=2043223; i=j;// convert long into float System.out.println(i); } } class tester{ public static void main(String agrs[]){ myclass my=new myclass(); my.method(); } } output = 2043223.0

Hi Rashid, quoting Rana Thakur: Rana Thakur greenhorn posted February 27, 2001 08:14 AM -------------------------------------------------------------------------------- Hi, The value for a long variable will be stored as 64 bits. However the floating point value will be stored in 32 bits in IEEE floating point format.i.e left most bit for sign bit, next 7 bits from the left for exponent and the remaining 24 bits for mantissa. Thus the value that can be stored using this format(maximum value being 3.4E+038) is much higher than that of the value that can be stored in a simple long variable(max value (2^63)-1). Hence the conversion is widening and not narrowing.

------------------------------------------------------ There was some discussion about this point in the forum. Search for "float". A float can take up a higher value then a long. The cost is lower precicion. hope this helps Axel