need to check for hex in C: how/

Gary Kline kline at thought.org
Sun Oct 16 22:41:44 UTC 2011


On Sun, Oct 16, 2011 at 11:07:59PM +0100, Matthew Seaman wrote:
> Date: Sun, 16 Oct 2011 23:07:59 +0100
> From: Matthew Seaman <m.seaman at infracaninophile.co.uk>
> Subject: Re: need to check for hex in C: how/
> To: freebsd-questions at freebsd.org
> 
> On 16/10/2011 22:26, Gary Kline wrote:
> > if n == 15 and x is the int. i can say 
> > 
> > if ((int)x == 15)  Or to check if x == 'A' i can cast x to (char)x.
> > 
> > what's the syntax to chec if x is , say, 32/
> 
> In C code you can write an integer constant in hexadecimal by prefixing
> it with 0x -- so 0x32 is the hexadecimal constant equal to decimal 50.
> 
>  if ( x == 0x32 ) ...
> 
> I guess that's what you're asking; '32/' is not any sort of syntax I've
> ever seen before to indicate hexadecimal.


	touche.  we've got (char), (int), (long), and (long long); i
	always assumed there was a (hex).  your ( x ==0x[hex]) will
	insure things don't fault because of, say, 'bad memory' or
	the like:)
	thankee,

	gary

> 
> 	Cheers,
> 
> 	Matthew
> 
> Tempted to interpret it as 32 shillings old money (£1.60 in decimal coinage)
> 
> -- 
> Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
>                                                   Flat 3
> PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
> JID: matthew at infracaninophile.co.uk               Kent, CT11 9PW
> 



-- 
 Gary Kline  kline at thought.org  http://www.thought.org  Public Service Unix
           Journey Toward the Dawn, E-Book: http://www.thought.org
          The 8.51a release of Jottings: http://jottings.thought.org



More information about the freebsd-questions mailing list