473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

converting to bits

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
6 7027
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
> Yes.

Yes!.... but where??

Greetings,
Rick
Jul 17 '05 #3
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
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
* 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Krista Bailie | last post by:
I'm sure this is so easy that it will hurt for anyone to read it, but I really need some direction. I'm trying to create a color chart (RGB) that shows steps between two different colors as...
22
by: Keith MacDonald | last post by:
Hello, Is there a portable (at least for VC.Net and g++) method to convert text between wchar_t and char, using the standard library? I may have missed something obvious, but the section on...
7
by: Jus! | last post by:
Hi. I am reading bits(1's & 0's) from a file and i wa wondering what is the most efficient method of converting these strings to individual int's? eg. File contains: 110001 010011 etc......
25
by: TK | last post by:
I'm used to programming in c or c++ in which my problem is simple. I want to be able to enter a value on a page (like 3.2), and then read it as a 32-bit float and break it into it's individual...
5
by: Code4u | last post by:
In the course of writing numerical code I needed to convert a float to an int with a defined behavior: if the float is great than INT_MAX, set the int to INT_MAX, otherwise assign directly. The...
2
by: geskerrett | last post by:
In the '80's, Microsoft had a proprietary binary structure to handle floating point numbers, In a previous thread, Bengt Richter posted some example code in how to convert these to python floats;...
8
by: Rick | last post by:
Hi, Does C have some handy functions to convert chars, ints and floats to bit arrays? I need to store that stuff binary so a few functions would be great. Converting chars and ints isn't...
11
by: Penfold | last post by:
I'd appreciate help converting student average test scores into grades. My problem is that I need to allocate one of about 20 grades (3a,3b,3c,4a,4b,4c etc through to 8c plus a couple of others)....
6
by: iwdu15 | last post by:
hi, how can i convert type Short to Unicode strings? the System.Text.UnicodeEncoding cant convert it if the length is too shrot....so i need to do this manually. how can i do this -- -iwdu15
3
by: news.microsoft.com | last post by:
Hello, I'm a VB.NET guy converting a C# app to VB.NET and ran into an issue. Steping through both the C# and VB.NET apps i get identical results but for one section. Notes: bit_buffer = 360...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.