Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / September 2006

Tip: Looking for answers? Try searching our database.

Add Method

Thread view: 
shiv - 22 Sep 2006 21:10 GMT
hi, i need help with this method please. if anyone can help, i will
apreciated. A method called getUnsignedValue.  This method should
calculate and return the decimal number equivalent to the binary number
stored in the object.  This method should simply return the integer
equivalent of the Binary number object.  The calculation is performed
assuming that the binary number object is in standard binary notation,
and therefore does not have negative values.  Note: this method should
NOT change the data stored inside the object!
Andrew Thompson - 23 Sep 2006 01:35 GMT
> hi, i need help with this method please.

What do you have so far (besides a problem description)?

Andrew T.
Matt Humphrey - 24 Sep 2006 18:02 GMT
> hi, i need help with this method please. if anyone can help, i will
> apreciated. A method called getUnsignedValue.  This method should
[quoted text clipped - 4 lines]
> and therefore does not have negative values.  Note: this method should
> NOT change the data stored inside the object!

It's not entirely clear what you're asking.  All data in the computer are in
binary, so is your object simply an Integer or even an int?  What do you
mean by decimal equivalent?  Do you mean to convert the number to a string?
"Standard" binary notation (2's complement in my world) includes negative
numbers, so you are saying this binary number is already unsigned?  And
Integers are already immutable.

My guess is that this is an exercise for a 1st-year computer science course
and it means to convert positive number (probably in an int) into a String
for display--a very common type of exercise.

You'll have to explain more about what you're trying to do.

Matt Humphrey matth@ivizNOSPAM.com http://www.iviz.com/
Joan C - 30 Sep 2006 10:00 GMT
> hi, i need help with this method please. if anyone can help, i will
> apreciated. A method called getUnsignedValue.  This method should
[quoted text clipped - 4 lines]
> and therefore does not have negative values.  Note: this method should
> NOT change the data stored inside the object!

This will do what you want

/**
* returned the unsigned value as an int
*/
public int getUnsigned( byte b)
{
int result = 0;
 if ((b & 0x80) != 0)
{
 result = (int) 0x80;
}
else
 result = 0;
result += (0x7f & b);
return result;
}
IchBin - 30 Sep 2006 17:31 GMT
>> hi, i need help with this method please. if anyone can help, i will
>> apreciated. A method called getUnsignedValue.  This method should
[quoted text clipped - 22 lines]
>  return result;
> }

Looks like someone had their homework assignment done for them..?

Signature

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA              http://weconsultants.phpnet.us
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.