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
rossum - 04 Aug 2007 10:12 GMT
>Hi friends,
>
[quoted text clipped - 11 lines]
>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
Roedy Green - 04 Aug 2007 19:25 GMT
>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

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com