how to coonvert decimal number in tobase 64 format.

Discussion in 'Java' started by naveen, Aug 4, 2007.

  1. naveen

    naveen Guest

    Hi friends,

    My requirement is how to coonvert decimal number in
    tobase 64 format.

    the decimal number may be of type.

    Example:
    123,123.456,-123,-123.556

    If any one knows any java API for this and how to use please send it
    me.


    Thanks,
    Naveen
    naveen, Aug 4, 2007
    #1
    1. Advertising

  2. naveen

    rossum Guest

    On Fri, 03 Aug 2007 23:57:20 -0700, naveen <>
    wrote:

    >Hi friends,
    >
    > My requirement is how to coonvert decimal number in
    >tobase 64 format.
    >
    >the decimal number may be of type.
    >
    >Example:
    > 123,123.456,-123,-123.556
    >
    >If any one knows any java API for this and how to use please send it
    >me.
    >
    >
    >Thanks,
    >Naveen


    1 Look up how to convert integers from base 10 to binary, octal or
    hexadecimal. Repeat the same process replacing 2, 8 or 16 with 64.
    This works for both integers and the integer part of real numbers.


    2 For the fractional part left once you have converted the integer
    part just multiply repeatedly by your base and extract the whole
    number part, which might be zero. The remaining fractional part is
    cycled round again until either it goes to zero or repeats.

    Example, 0.3 to binary fraction:

    0.3 x 2 = 0.6 -> 0
    0.6 x 2 = 1.2 -> 1
    0.2 x 2 = 0.4 -> 0
    0.4 x 2 = 0.8 -> 0
    0.8 x 2 = 1.6 -> 1
    etc.

    0.3 decimal = 0.010011001(1001)... binary fraction


    rossum
    rossum, Aug 4, 2007
    #2
    1. Advertising

  3. naveen

    Roedy Green Guest

    Re: how to convert decimal number into base 64 format

    >My requirement is how to convert a decimal number into
    >base 64 format.

    That question could have two meanings.
    base64 is a common encoding.
    You first have to convert to a byte array.
    You would do that with Double.doubleToLongBits,
    then break into bytes.
    See http://mindprod.com/jgloss/base64.html
    You might also mean base 64 in the sense of
    binary, octal, hex, base 64.
    See http://mindprod.com/jgloss/radix.html
    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Aug 4, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shannon
    Replies:
    1
    Views:
    8,592
  2. shannon
    Replies:
    0
    Views:
    569
    shannon
    Feb 1, 2006
  3. Alex Shen
    Replies:
    5
    Views:
    418
    Alex Shen
    Oct 30, 2010
  4. Oscar Lok
    Replies:
    1
    Views:
    168
    David Kastrup
    Nov 19, 2006
  5. Fei Liu
    Replies:
    21
    Views:
    2,348
    John Bokma
    Dec 16, 2006
Loading...

Share This Page