Search This Blog

Monday, June 16, 2008

DEFINING VARIABLES IN OCTAL AND HEXADECIMAL

Often, when writing systems programs, the programmer needs to use a different number base rather than the default decimal. Integer constants can be defined in octal or hex by using the associated prefix, e.g., to define an integer as an octal constant use %o int sum = %o567; To define an integer as a hex constant use %0x int sum = %0x7ab4; int flag = %0x7AB4; /* Note upper or lowercase hex ok */

No comments: