need to check for hex in C: how/
Robert Bonomi
bonomi at mail.r-bonomi.com
Sun Oct 16 21:52:05 UTC 2011
> From owner-freebsd-questions at freebsd.org Sun Oct 16 16:27:46 2011
> Date: Sun, 16 Oct 2011 14:26:31 -0700
> From: Gary Kline <kline at thought.org>
> To: FreeBSD Mailing List <freebsd-questions at 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.
More information about the freebsd-questions
mailing list