primitive « float « Java Data Type Q&A





1. Is there any difference between these two statements?    stackoverflow.com

  1. float ff = 1.2f;
  2. Float fo = new Float(1.2f);
  3. double fg = 3.2d;
  4. Double fh = new Double(2.1d);
Can I use '=' between the (1) and (3) or between the (2) and (4)?? ...

2. For what purpose does java have a float primitive type?    stackoverflow.com

Can you help me clarify the usages of the float primitive in Java? My understanding is that converting a float value to double and vice-versa can be problematic. I read (rather long ...

3. VisualVM OQL: how to search for primitive float values rather than actual Float instances?    stackoverflow.com

I am wondering how one can search for all primitive float values that match a certain number. When doing something like:

select n from java.lang.Float n where n.value == 1.00
Only the Float ...

4. Getting a Java field through reflection, but not from its String name    stackoverflow.com

Is it possible to get a Field through Java reflection if I have the field itself? It's a primitive float (public, no problem). I don't want to use its name as ...

5. How can a primitive float value be -0.0? What does that mean?    stackoverflow.com

How come a primitive float value can be -0.0? What does that mean?
Can I cancel that feature? When I have:

  float fl;  
Then fl == -0.0 returns true and so ...

6. float primitive and its.... crazyness?!?!    coderanch.com

Andree, I would say that in "literal" terms, the default value of a float is actually "0.0f". When you forget to append the "f", it will treat literals as literal double values. And since a double has more bytes than a float, the compiler will generate an error when you attempt to assign "0.5" to it. However, as I mentioned, setting ...

8. Floating points Primitive data Type    forums.oracle.com

New to oracle forums, new to java. Hi to all, and there is my question... Literal values for floating points are assumed to be of type double unless specified otherwise. However a double floating point takes 64 bits of memory and a float needs 32. Why is the default set from Java to double and not to float in order to ...

9. Question about float and double primitives    forums.oracle.com