From owner-freebsd-questions Sat Jan 27 11:20:21 2001 Delivered-To: freebsd-questions@freebsd.org Received: from guru.mired.org (okc-65-26-235-186.mmcable.com [65.26.235.186]) by hub.freebsd.org (Postfix) with SMTP id 3773137B400 for ; Sat, 27 Jan 2001 11:20:02 -0800 (PST) Received: (qmail 40056 invoked by uid 100); 27 Jan 2001 19:20:01 -0000 From: Mike Meyer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14963.8033.752142.149320@guru.mired.org> Date: Sat, 27 Jan 2001 13:20:01 -0600 (CST) To: "Mark B. Withers" Cc: questions@freebsd.org Subject: Re: hexidecimal literacy In-Reply-To: <19700761@toto.iv> X-Mailer: VM 6.75 under 21.1 (patch 10) "Capitol Reef" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Mark B. Withers types: > Oh gosh! > > I thought I understood it before, but looking at it like this > simplifies it dramaticly!! Just remember that this applies to interesting bases like 0, 1, Pi and negative numbers :-). On Sat, Jan 27, 2001 at 03:31:17AM -0500, Donald J . Maddox wrote: > > Here's how it really works: > > > > Normally, we use base 10 numbers. What this means is that a number > > like "19,784" is interpreted as: > > > > 1 9 7 8 4 > > ^ ^ ^ ^ ^ > > | | | | |__ 4 x 10 ^ 0 + > > | | | |____ 8 x 10 ^ 1 + > > | | |______ 7 x 10 ^ 2 + > > | |________ 9 x 10 ^ 3 + > > |__________ 1 x 10 ^ 4 > > > > Hexadecimal numbers are exactly the same except that they use powers > > of 16 instead of 10. So, 0x19784 is interpreted as: > > > > 1 9 7 8 4 > > ^ ^ ^ ^ ^ > > | | | | |__ 4 x 16 ^ 0 + > > | | | |____ 8 x 16 ^ 1 + > > | | |______ 7 x 16 ^ 2 + > > | |________ 9 x 16 ^ 3 + > > |__________ 1 x 16 ^ 4 > > > > When using base 10 numbers, there are 10 symbols required, 0-9. When > > using hexadecimal numbers, there are 16 symbols required, 0-9 and a-f, > > where a-f would be 10,11,12,13,14,15 in decimals, so counting in hex > > goes like this: > > > > 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f, 10, 11, 12, 13, 14, 15, > > 16, 17, 18, 19, 1a, 1b ... > > > > Note that 0x16 = 1 x 16 ^ 1 + 6 x 16 ^ 0, which would be 22 in decimal. > > > > Is any of this making sense? :) > > > > On Sat, Jan 27, 2001 at 02:47:23AM -0500, Mark B. Withers wrote: > > > Kewl! > > > > > > Thanks everyone for the help! I've studied it before but am quite > > > rusty. > > > > > > Mark > > > > > > On Sat, Jan 27, 2001 at 02:30:15AM -0500, Christopher Farley wrote: > > > > Mark B. Withers (mwithers@one.net) wrote: > > > > > > > > > I was wondering if someone could help me with understanding > > > > > hexidecimal numbers used in FreeBSD? > > > > > > > > This reminds me of the Onion story "Microsoft Patents 1s, 0s"... > > > > > > > > > I can relate mentally to the concept that the numeral system is based > > > > > on 16 instead of 10 like decimal numbers are. > > > > > > > > > > Is the prefix 0x always used? What does the 0x mean? > > > > > > > > The prefix 0x is always used to denote a hexidecimal number. The prefix > > > > 0 is used to denote an octal (base-8) number. > > > > > > > > Why ask why? > > > > > > > > > Would the hexidecimal number 0xf mean 16? > > > > > > > > Actually, it's 15. 0x10 would be 16. > > > > > > > > -- > > > > Christopher Farley > > > > www.northernbrewer.com > > > > > > > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > > > > with "unsubscribe freebsd-questions" in the body of the message > > > > > > > > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > > > with "unsubscribe freebsd-questions" in the body of the message > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message > -- Mike Meyer http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message