Re: Binary to Hexadecimal Conversion



On Sat, 30 Dec 2006 14:13:50 -0000, lei <m_de_robles@xxxxxxxxx> wrote:


Daniel Dyer wrote:
On Sat, 30 Dec 2006 09:31:44 -0000, lei <m_de_robles@xxxxxxxxx> wrote:

> you can also suggest for improvements..thanks!

It could be so much simpler:

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Integer.html#parseInt(java.lang.String,
int)
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Integer.html#toHexString(int)

Everything after reading the input could be replaced with this one line:

Integer.toHexString(Integer.parseInt(input, 2));

Dan.

I can't use it. The idea is to create your own toHexString.

OK, that wasn't immediately clear.

Dan.

--
Daniel Dyer
https://watchmaker.dev.java.net - Evolutionary Algorithm Framework for Java
.



Relevant Pages

  • Re: fread()
    ... > int i,istat,iaccum,intype; ... reading binary data from standard input? ... Use sizeof (float), or even better, sizeof *floatarray, instead. ... FLOAT, and set istat accordingly? ...
    (comp.lang.c)
  • Re: Opening a PPM file Image
    ... Just create a CFile object and open it in binary mode for reading, ... int height; ... int rowsize = width; ...
    (microsoft.public.vc.mfc)
  • Re: frustrated by fscanf and sscanf
    ... no threads talking about reading a series of numbers. ... The input files, somehow structured, is exemplified below: ... int SIZE; ... Reading 2 12X12 arrays of double. ...
    (comp.lang.c)
  • Problem with shared library generated on Solaris 8 X86
    ... trondn@solsrv2 cctest> uname -a ... Reading testprog ... extern int func; ...
    (comp.unix.solaris)
  • Re: Rookie Student C++ Array question (reading from a file)
    ... >>stars for the number of times the number occurred (a histogram). ... but the output is telling me no cigar. ... >>int main{ ... >> It's reading fine from the data file. ...
    (alt.comp.lang.learn.c-cpp)