Click here to Skip to main content
15,920,645 members
Home / Discussions / Java
   

Java

 
AnswerRe: Web Services Pin
Pravin Patil, Mumbai7-Mar-11 20:05
Pravin Patil, Mumbai7-Mar-11 20:05 
QuestionShift operations with float and double Pin
Kujtim Hyseni7-Mar-11 0:25
Kujtim Hyseni7-Mar-11 0:25 
AnswerRe: Shift operations with float and double Pin
Richard MacCutchan7-Mar-11 6:53
mveRichard MacCutchan7-Mar-11 6:53 
AnswerRe: Shift operations with float and double Pin
User 75994147-Mar-11 13:57
User 75994147-Mar-11 13:57 
AnswerRe: Shift operations with float and double Pin
David Skelly7-Mar-11 22:22
David Skelly7-Mar-11 22:22 
GeneralRe: Shift operations with float and double Pin
Richard MacCutchan8-Mar-11 0:07
mveRichard MacCutchan8-Mar-11 0:07 
AnswerRe: Shift operations with float and double Pin
TorstenH.10-Mar-11 1:05
TorstenH.10-Mar-11 1:05 
AnswerRe: Shift operations with float and double Pin
parths10-Mar-11 19:09
parths10-Mar-11 19:09 
I'm assuming that you want to use the bit-representation of the floating point value with the shift operators to create a float from a byte-stream, and vice-versa

The java Float class (here[^]) contains functions:
floatToIntBits, floatToRawIntBits -- Convert from a float to an integer containing the float value's bit representation
intBitsToFloat: Converts an integer value (containing a float value's bit representation) to a Float variable.

So basically you can do something like:
byte[] data = ...;
int rdInt = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); // Or the other way round depending on endian-ness.
float rdFloat = Float.intBitsToFloat(rdInt);


... And do the opposite to convert back from float to bytes.


"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman

"Philosophy is a study that lets us be unhappy more intelligently."
-Anon.



QuestionJava Java EE Pin
future38396-Mar-11 14:33
future38396-Mar-11 14:33 
AnswerRe: Java Java EE Pin
Richard MacCutchan8-Mar-11 0:07
mveRichard MacCutchan8-Mar-11 0:07 
AnswerRe: Java Java EE Pin
TorstenH.9-Mar-11 4:28
TorstenH.9-Mar-11 4:28 
AnswerRe: Java Java EE Pin
shi-fj31-Mar-11 4:59
shi-fj31-Mar-11 4:59 
Question[ASK] about create file in directori Pin
kellyyy6-Mar-11 8:01
kellyyy6-Mar-11 8:01 
AnswerRe: [ASK] about create file in directori Pin
DaveAuld6-Mar-11 8:31
professionalDaveAuld6-Mar-11 8:31 
GeneralRe: [ASK] about create file in directori Pin
kellyyy8-Mar-11 5:27
kellyyy8-Mar-11 5:27 
GeneralRe: [ASK] about create file in directori Pin
TorstenH.9-Mar-11 4:32
TorstenH.9-Mar-11 4:32 
AnswerRe: [ASK] about create file in directori Pin
musefan7-Mar-11 0:13
musefan7-Mar-11 0:13 
GeneralRe: [ASK] about create file in directori Pin
kellyyy8-Mar-11 6:19
kellyyy8-Mar-11 6:19 
GeneralRe: [ASK] about create file in directori Pin
TorstenH.9-Mar-11 4:31
TorstenH.9-Mar-11 4:31 
QuestionTCP Socket Chat-Receive msg on JTextArea Pin
Ireland.ir6-Mar-11 6:38
Ireland.ir6-Mar-11 6:38 
AnswerRe: TCP Socket Chat-Receive msg on JTextArea Pin
Richard MacCutchan6-Mar-11 22:39
mveRichard MacCutchan6-Mar-11 22:39 
GeneralRe: TCP Socket Chat-Receive msg on JTextArea Pin
Ireland.ir7-Mar-11 1:47
Ireland.ir7-Mar-11 1:47 
QuestionHow to get sound from other apps? [modified] Pin
mk_45-Mar-11 13:13
mk_45-Mar-11 13:13 
Questionnoob question on new Pin
Budlee4-Mar-11 7:56
Budlee4-Mar-11 7:56 
AnswerRe: noob question on new Pin
exiles.prx_ac4-Mar-11 15:49
exiles.prx_ac4-Mar-11 15:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.