473,408 Members | 2,402 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,408 software developers and data experts.

Working with bytes

I need to convert 11011101 to a byte but when I try:
Expand|Select|Wrap|Line Numbers
  1. Byte.valueOf("11011101", 2);
  2.  

Error:
Expand|Select|Wrap|Line Numbers
  1. Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: Value out of range. Value:"11011101" Radix:2
  2.  

What I have to do to decide this problem?
How I decide this problem with the band of representation of a byte?
Jun 27 '07 #1
9 5929
r035198x
13,262 8TB
I need to convert 11011101 to a byte but when I try:
Expand|Select|Wrap|Line Numbers
  1. Byte.valueOf("11011101", 2);
  2.  

Error:
Expand|Select|Wrap|Line Numbers
  1. Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: Value out of range. Value:"11011101" Radix:2
  2.  

What I have to do to decide this problem?
How I decide this problem with the band of representation of a byte?
But it's telling you that the value is out of range. It's too big to be stored as a byte.
Jun 28 '07 #2
praveen2gupta
201 100+
Hi

Byte data type can store maximum 127 decimal number value. If you try to store more than that it wil show errors at compiler.

If you numbr is in binary and you wants to convert it in decinal then . I think you should read a begainners level book.
Jun 28 '07 #3
I know that, but i'd like to know if have a possibility to represent a decimal > 127 in just 1 byte, how I can do that? This is possible ?

Theoretically: 1 byte have 8 bits, so can be 11011101 for example.
Jun 28 '07 #4
r035198x
13,262 8TB
I know that, but i'd like to know if have a possibility to represent a decimal > 127 in just 1 byte, how I can do that? This is possible ?

Theoretically: 1 byte have 8 bits, so can be 11011101 for example.
I hope you are not confusing changing to binary and changing to byte.
Jun 28 '07 #5
JosAH
11,448 Expert 8TB
@OP: note that you can cast an int back to a byte in which case the lowest
eight bits are stored in the byte. (hint, hint ;-)

kind regards,

Jos
Jun 28 '07 #6
r035198x
13,262 8TB
@OP: note that you can cast an int back to a byte in which case the lowest
eight bits are stored in the byte. (hint, hint ;-)

kind regards,

Jos
About time you showed up.
You have no idea what mess I've been getting myself into.
Jun 28 '07 #7
JosAH
11,448 Expert 8TB
About time you showed up.
You have no idea what mess I've been getting myself into.
What's the mess then? I saw a very slow thread going on about Exceptions, but
that was about it. This thread's problem is almost solved thanks/due to my all
spoiling hint ;-)

kind regards,

Jos (still got work to do but I'll take a peek here now and then)
Jun 28 '07 #8
r035198x
13,262 8TB
What's the mess then? I saw a very slow thread going on about Exceptions, but
that was about it. This thread's problem is almost solved thanks/due to my all
spoiling hint ;-)

kind regards,

Jos (still got work to do but I'll take a peek here now and then)
You haven't seen the private class declaration thread then.
Jun 28 '07 #9
JosAH
11,448 Expert 8TB
You haven't seen the private class declaration thread then.
Nope, I'm afraid not; what's the thread title? I'll take a look and see if I can create
an even greater mess out of it then ;-)

kind regards,

Jos
Jun 28 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Adam T. Gautier | last post by:
I have been unable to solve a problem. I am working with MD5 signatures trying to put these in a database. The MD5 signatures are not generated using the python md5 module but an external...
1
by: Larry Menard | last post by:
Folks, I've written the world's simplest java UDF, and it is complaining that it can't load the method. The class seems OK, it's complaining about the method. The JDBC Sample UDFs (e.g.,...
7
by: Alex | last post by:
Hello people, I have a code written in JAVA that creates field of bytes: byte uuid = new byte; Now I have to translate this line into C++. I'm working in VS 6.0. (unfortunately I have to)....
8
by: den 2005 | last post by:
Hi everybody, I am not sure where to put this in this forum. So, I posted this at several topics. I created a class library that has two public methods Encrypt() and Decrypt(). I reference this...
4
by: SpreadTooThin | last post by:
client: import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("192.168.1.101", 8080)) print 'Connected' s.send('ABCD') buffer = s.recv(4) print buffer s.send('exit')
6
by: RaulAbHK | last post by:
Dear all, I guess this is a basic question with an easy answer but I am a beginner and I would much apreciate your feedbacks. Let's say I have a library with some functionality to perform some...
0
by: George2 | last post by:
Hello everyone, I am using perfmon to watch the working set and virtual bytes, when I do a keyword search in SourceInsight. I found the value of working set is larger than virtual bytes when...
0
by: George2 | last post by:
Hello everyone, From the definition of working set, it is a subset of virtual pages resident in physical memory -- from book Windows Internals. It means working set could not be larger than...
3
by: PrabodhanP | last post by:
I have CSS based mouseover scrolling for divContent embeded in my webpage.It works fine in IE,but not working in mozilla-FF. It is located at the location.....
9
by: RichG | last post by:
I'm working with a data stream of 8 bytes in an embedded application. In most cases the data is byte aligned so I can define a structure and then memcpy the data directly to the structure elements. ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.