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 / General / August 2007

Tip: Looking for answers? Try searching our database.

how to coonvert decimal number  in tobase 64 format.

Thread view: 
naveen - 04 Aug 2007 07:57 GMT
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



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.