linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* printf format type, precision...
@ 2004-07-02 22:32 J.
  2004-07-02 23:10 ` wwp
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: J. @ 2004-07-02 22:32 UTC (permalink / raw)
  To: linux-c-programming

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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-07-02 23:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-02 22:32 printf format type, precision J.
2004-07-02 23:10 ` 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.

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