> From owner-freebsd-questi...@freebsd.org  Sun Oct 16 16:27:46 2011
> Date: Sun, 16 Oct 2011 14:26:31 -0700
> From: Gary Kline <kl...@thought.org>
> To: FreeBSD Mailing List <freebsd-questions@freebsd.org>
> Cc: 
> Subject: need to check for hex in C: how/
>
>
> 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/

The advice from my computer-science professor was 'try it and find out'.

It doesn't matter what anybody _says_ it is, the only thing that 
matters is what the computer (or, to be precise, the compiler) accepts?

Now, for some information that you could/should get from any elementary
book on C programming ("The C Programming Language", by Kerningan and
Ritchie [r.i.p., this last week] is recommended):

In general, you don't need _any_ explicit casts for those situations.

C does 'automatic' promotion of numeric items so they have comparable 
'width' for comparisons.

For more details, see the 'fine manual' mentioned above.

_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to