By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,468 Members | 1,859 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,468 IT Pros & Developers. It's quick & easy.

converting to bits

P: n/a
Hi,

Does Java has some handy functions to convert types to bits. I need to send
a strign filled with 0 and 1 so functions like
StringToBits( String s )
FloatToBits( float f )
IntToBits( int i )
would be great because I'm too lazy to write that shit on my own. And vice
versa, are their also functions to convert back?

Greetings,
Rick
Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Rick wrote:
Hi,

Does Java has some handy functions to convert types to bits. I need to
send a strign filled with 0 and 1 so functions like
StringToBits( String s )
FloatToBits( float f )
IntToBits( int i )
would be great because I'm too lazy to write that shit on my own. And vice
versa, are their also functions to convert back?


Yes.

--
Chris Gray ch***@kiffer.eunet.be

Jul 17 '05 #2

P: n/a
> Yes.

Yes!.... but where??

Greetings,
Rick
Jul 17 '05 #3

P: n/a
nos
what return type?

"chris" <ch***@kiffer.eunet.be> wrote in message
news:bo**********@reader10.wxs.nl...
Rick wrote:
Hi,

Does Java has some handy functions to convert types to bits. I need to
send a strign filled with 0 and 1 so functions like
StringToBits( String s )
FloatToBits( float f )
IntToBits( int i )
would be great because I'm too lazy to write that shit on my own. And vice versa, are their also functions to convert back?


Yes.

--
Chris Gray ch***@kiffer.eunet.be

Jul 17 '05 #4

P: n/a
Rick wrote:
Yes.


Yes!.... but where??

Greetings,
Rick


Well, there's a class called java.lang.Float and one called
java.lang.Double ... might be worth looking there? Just to see if you can
find methods called e.g. floatToIntBits or intBitsToFloat ...

For converting String to Integer, Integer.parseInt(string, radix) might be
a good place to start.

--
Chris Gray ch***@kiffer.eunet.be

Jul 17 '05 #5

P: n/a
* Rick <as******@hotmail.com>:
Hi,

Does Java has some handy functions to convert types to bits. I
need to send a strign filled with 0 and 1 so functions like StringToBits( String s )
FloatToBits( float f )
IntToBits( int i ) would be great because I'm too lazy to write that shit on my own.
And vice versa, are their also functions to convert back?


Don't curse.

To bits? No. To bytes, kinda. Look for classes that implement the
java.io.DataOutput interface. You might be able to wrap a
java.io.DataOuptutStream around a java.io.ByteArrayOutputStream.

Javi
Jul 17 '05 #6

P: n/a
nos
nah, he said he is lazy as shit
"chris" <ch***@kiffer.eunet.be> wrote in message
news:bo**********@reader11.wxs.nl...
Rick wrote:
Yes.


Yes!.... but where??

Greetings,
Rick


Well, there's a class called java.lang.Float and one called
java.lang.Double ... might be worth looking there? Just to see if you can
find methods called e.g. floatToIntBits or intBitsToFloat ...

For converting String to Integer, Integer.parseInt(string, radix) might be
a good place to start.

--
Chris Gray ch***@kiffer.eunet.be

Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.