🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #510

Converting to binary representation

#510
From: Peter Goldman
Date: Mon, 06 Jun 2005 20:22
14 lines
1399 bytes
I'm working on a java program which takes a byte value and shows binary representation.

I know that using Integer.toString(iVal, iRadix) can convert integer value to binary string representation. My problem is, if a value is negative, Integer.toString shows -111111 value instead real binary representation.

For example: 122 value in binary is: 01111010.
-122 value in binary is 10000110.
Using Integer.toString method, -122 is -1111010.

I need a way to show -122 in binary 10000110. I don't know if java class library provides additional resources to perform this task.

I appreciate some help.

Best Regards.
Technical Details
Message-ID: <42a4b083$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,55aa53c82de6ba30,start
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Peter Goldman" <no@no.no>
Sender: "Peter Goldman" <no@no.no>
Reply-To: "Peter Goldman" <no@no.no>
Subject: Converting to binary representation
Newsgroups: borland.public.jbuilder.java.language
X-User-Info: 200.64.192.235     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <42a4b083$1@newsgroups.borland.com>
Date: 6 Jun 2005 13:22:27 -0700
X-Trace: newsgroups.borland.com 1118089347 207.105.83.66 (6 Jun 2005 13:22:27 -0700)
Lines: 16
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail