>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)