byte « float « Java Data Type Q&A

1. Byte upgraded to float?

Hi, please have a look over the following code, and tell me why the Byte type variable is also being upgraded to Float type while calling as a function argument? The Integer variable is understandably upgraded to Float, but why Byte, even when the definition of function with Byte argument is available? class ArithTest { public static void main(String args[]) { ...

2. byte[] to float

3. Float to []byte

Those bytes do not match the byte representation of that float. Rather, they match the byte representation of that value as a long. For instance, the float 1.0 (or 1,0) is the bytes 0x3f800000, NOT the bytes 0x00000001. Please be clear as to what exactly you're trying to do. Edited by: jverd on Sep 9, 2009 12:05 PM

4. Floating point number to IBM bytes

Hello, I'm trying to convert a float value to a byte array (but in IBM standard). I understand that the general idea will be the following algorithm: 1. process the sign, exponent and fraction from the float value (using IBM standard) 2. build the bytes from the S, E, F from step 1. So far, I only have the step 2 ...