Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Number Base Converter
Message
De
25/06/2004 11:45:10
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
25/06/2004 07:07:54
Fabian Belo
Independent Developer
Argentine
Information générale
Forum:
Java
Catégorie:
Autre
Divers
Thread ID:
00917041
Message ID:
00917264
Vues:
11
>Thank you Hilmar, it helps. (espacially octal stuff)

You are welcome. You don't happen to need the opposite conversion (from decimal to other bases)?

>
>>>Dear all;
>>>
>>>Does anyone has an algorithm to convert from base 8/16/2 to base 10?
>>>Thanks.
>>
>>Let's see an example in octal:
>>
>>234 (octal)
>>
>>2 should be multiplied by 8^2 (8 square; right now, I don't remember the syntax in Java). 2 should be multiplied by 8, and 4, simply by 1.
>>
>>A shortcut, which sort of bypasses the use of powers, is:
>>
>>(2 * 8 + 3) * 8 + 4
>>
>>IOW: repeatedly multiply by 8, and add the next digit.
>>
>>For hexadecimal, you would have to convert "A" to 10... "F" to 15, first, and then apply the same algorithm (multiplying by 16, of course).
>>
>>HTH,
>>
>>Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform