public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: dhruv pant <dhpant28@gmail.com>
To: "Ángel González" <keisial@gmail.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: using hex in gcc
Date: Thu, 07 Jun 2012 06:34:00 -0000	[thread overview]
Message-ID: <CAAdqfvaZ6bfh69Mz+D_+XbpDv2rdmq1-wZBu_gzGJbycEx2P0g@mail.gmail.com> (raw)
In-Reply-To: <4FCFBE5C.6060404@gmail.com>

thanks got it...i was actually  thinking in some other way....
so basically everything is actually stored in binary form.it's for our
convenience and readability that we are converting them to hex or
decimal.....
so suppose...
unsigned int i=10
printf("%x",i) //this will print the hex equivalent of 10?

On 6/7/12, Ángel González <keisial@gmail.com> wrote:
> On 06/06/12 19:14, dhpant2806 wrote:
>> i want to test some code having hex variable in gcc.how can i do it
> What do you mean? Your question doesn't make much sense.
> You don't have 'hex' variables. The way the values are stored is specific
> to the architecture you are compiling to (just think that they are
> "stored as bits").
> Decimal, hexadecimal, binary, etc. is how we input them (in writing the
> literals)
> or output them.
>
> I have no idea if this is what you wanted, but take a look at the
> following program:
>
> #include <stdio.h>
>
> int main() {
>     int variableA = 42;
>     int variableB = 0x33;
>     printf("Variable A: %d decimal - %x hexadecimal\n", variableA,
> variableA);
>     printf("Variable B: %d decimal - %x hexadecimal\n", variableB,
> variableB);
>     return 0;
> }
>
>

  reply	other threads:[~2012-06-07  6:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-06 17:14 dhpant2806
2012-06-06 20:33 ` Ángel González
2012-06-07  6:34   ` dhruv pant [this message]
2012-06-07 11:06     ` Andrew Haley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAdqfvaZ6bfh69Mz+D_+XbpDv2rdmq1-wZBu_gzGJbycEx2P0g@mail.gmail.com \
    --to=dhpant28@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=keisial@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).