linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: wwp <subscript@free.fr>
To: linux-c-programming@vger.kernel.org
Subject: Re: printf format type, precision...
Date: Sat, 3 Jul 2004 01:10:40 +0200	[thread overview]
Message-ID: <20040703011040.17c21d51@tethys.solarsys.org> (raw)
In-Reply-To: <Pine.LNX.4.21.0407030018090.1619-100000@hestia>

Hello J.,


On Sat, 3 Jul 2004 00:32:27 +0200 (CEST) "J." <mailing-lists@xs4all.nl> wrote:

> 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..

You meant:
 printf("%ld\n", result);
instead of:
 printf("%ld\n", value);

What do you get, what do you expect?


Regards,

-- 
wwp

  reply	other threads:[~2004-07-02 23:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-02 22:32 printf format type, precision J.
2004-07-02 23:10 ` wwp [this message]
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=20040703011040.17c21d51@tethys.solarsys.org \
    --to=subscript@free.fr \
    --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).