[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: converting numbers



At 11:48 AM 1/28/99 -0800, David Stern wrote:
>On Thu, 28 Jan 1999 12:17:34 CST, Andrew Ivanov wrote:
>> > Howdy,
>> > 
>> > Where's the FM that tells how to convert numbers, like 0x11A to a 
>> > "decimal"?
>> 
>> 0x11A is in hex, and to convert it to dec is
>> 1*16^2 + 1*16^1 +10*16^0
>> (A=10,B=11, C=12, D=13, E=14, F=15)
>
>I should never have asked this question before having some coffee. :-)
>
>> I may be wrong, but I think octal is in x0# format, so that 
>> 0x0300 would be an octal number.
>> To convert that to dec is
>> just 3*8^2+0*8^1+0*8^0, and ignore the leading 0 after x, which is used to
>> idenbtify the radix.
>
>OK, hex numbers are radix 16, octal radix 8, decimal radix 1.
>
>So, a leading "0x" indicates hex, and a leading "0" traditionally 
>indicates octal, although the latter may require contextual information 
>to distinguish between decimal, which should not be written with a 
>leading zero, if I read Henning Makholm correctly (thanks Henning!), 
>and I'll disregard the mention of binary.
>
>Good.  Now I can convert between hex, octal and decimal.  
>
>I guess I'll have to determine when to use each based on context.
>
>Thanks!  Now, where is that coffee? :-)


http://amelia.experiment.db.erau.edu/ldp/HOWTO/mini/Coffee.html


>-- 
>David
>dstern@u.washington.edu
>
>
>
>-- 
>Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org <
/dev/null
>
>


Reply to: