long « float « Java Data Type Q&A

Home
Java Data Type Q&A
1.bigdecimal
2.biginteger
3.bit
4.Boolean
5.byte
6.Calendar
7.cast
8.character
9.Date Time
10.Date Time Format
11.decimal
12.Development
13.double
14.enum
15.float
16.hexadecimal
17.Integer
18.Number
19.Number Format
20.primitive
21.SimpleDateFormat
22.string
23.StringBuffer
24.StringBuilder
25.StringTokenizer
26.substring
27.TimeZone
Java Data Type Q&A » float » long 

1. Java - int/long, float/double    stackoverflow.com

I understand that "2.5" is automatically a double, and to make it a float, I need to do "2.5F" (or should the F be lowercase?), and that I should use a ...

2. final byte cant type cast float, long and double    coderanch.com

Hi babu jayaraman This showed Exception because it can not do the autoboxing . Means autoboxing supports only in jdk 1.5.0 not other versions In this coding public byte Test() { final int i=127; final float f=127; return i; // Its working fine //return f;// but is not working, i dont know the logic, } Return type is byte , but ...

3. Long -> float    coderanch.com

Hello, According the exam guide I am using, it is possible to covert an long value to a float value. They explain the other conversion saying 'widening' which means a 32 bit data type hold a 16 bit data type and so on. But the explanation for my question is not given. So could you please explain how this is possible. ...

4. float to long typecasting    coderanch.com

Hi i don't know how java stores floating point numbers in memory.(distribution of absolute and fraction digits) a long takes 8 byte while a float takes 4 bytes only so why can't we typecast a float to a long implicitly. why widening isn't followed here in this case and why a long can be type casted to a float implicitly while ...

5. Long to float?    forums.oracle.com

6. How can float hold a value of long type?    forums.oracle.com

7. float or long?    forums.oracle.com

8. problem in placing float value to long    forums.oracle.com

Thnks for reply. I had tried this code public class Test { public static void main(String ar[]) { long longVal = 9223372036854775807L; System.out.println("\nlongVal: "+longVal); float floatVal = longVal; System.out.println("flaotVal: "+floatVal); } } Output is longVal: 9223372036854775807 flaotVal: 9.223372E18 evalution of floatVal is 9223372000000000000 So ther is data loss of long val. Thnks in advance

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.