File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Can I twiddle those float bits? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Can I twiddle those float bits?" Watch "Can I twiddle those float bits?" New topic

Can I twiddle those float bits?

Darrin Cartwright
Ranch Hand

Joined: Dec 27, 2002
Posts: 107
Howdy All!
I need to combine two 16-bit values into a single 32-bit float. That is, I have a float (32 bits)that has been broken into two shorts (16 bits each) and I need to recombine the shorts to recreate the value. It's easy to make an int out of them, but you can't use bit operators on a floating point number.

Life is good on the Ponderosa,<br />but mind where you step.
Darrin Cartwright
Ranch Hand

Joined: Dec 27, 2002
Posts: 107
Note to self: Check out the Float.intBitsToFloat() method!
Sorry about the post, but thanks for lookin!
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Gotta love a guy that answers his own post .

"JavaRanch, where the deer and the Certified play" - David O'Meara
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
...though we should probably point out that our display name policy does forbid "obviously fictitious" names. Please edit your profile to change it to a real name (or at least, one that looks real). Although you do get points for a nice clever one that even fits in pretty well with our ranch motif. Thanks.

"I'm not back." - Bill Harding, Twister
I agree. Here's the link:
subject: Can I twiddle those float bits?
Similar Threads
Range of Datatypes
Data types back ward compatability
char compability...
Math.round Question