linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J." <mailing-lists@xs4all.nl>
To: linux-c-programming@vger.kernel.org
Subject: printf format type, precision...
Date: Sat, 3 Jul 2004 00:32:27 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.21.0407030018090.1619-100000@hestia> (raw)

Saturday, July 03 00:18:09

Hello,

I am trying to convert an IP address to it's eq. in base10
[homework]. However the outcome from the formula listed below isn't giving
me the right results.  Is this because I'm using the wrong precision type
for the `result' variable ? If that's the case what other precision type
should I use instead ? Right now I can't see the format tree's trhu the
precision forrest anmore .. ehum.

#include <stdio.h>

int main(void) {
 int var1 = 192; 
 int var2 = 168;
 int var3 = 1;
 int var4 = 10;
 long int result = 0;

 result = var1 * (256 ^ 3) + var2 * (256 ^ 2) * var3 * 256 + var4; 
 printf("%ld\n", value);

 return 0;
}

Your comments and suggestions will be greatly appreciated..

Thnks..!

J.


             reply	other threads:[~2004-07-02 22:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-02 22:32 J. [this message]
2004-07-02 23:10 ` printf format type, precision wwp
2004-07-02 23:29   ` J.
2004-07-02 23:11 ` Glynn Clements
2004-07-02 23:19 ` wwp
2004-07-02 23:36   ` printf format type, precision... Solved J.

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=Pine.LNX.4.21.0407030018090.1619-100000@hestia \
    --to=mailing-lists@xs4all.nl \
    --cc=linux-c-programming@vger.kernel.org \
    /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 NNTP newsgroup(s).