Subject: Re: 64-bit network byte order
To: chintan sheth <>
From: Roland Dowdeswell <>
List: tech-kern
Date: 04/23/2002 22:03:42
On 1019599649 seconds since the Beginning of the UNIX epoch
chintan sheth wrote:
>> Hi,
>> What will be the network byte order value of the
>> following 64 bit value:
>>         0000 02c1 1001 0002
>> Kindly reply asap.

Sure:  this is an inspecific question since you have not stated what
byte order the original value is in.  Two byte orders are prevalent on
most hardware that is available today, little endian and big endian.
Network byte order is big endian.  If you don't know the byte order,
run the following little program:

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

#include <sys/endian.h>

	fprintf(stderr, "usage: tonetworkbyteorder <num>\n");

main(int argc, char **argv)
	u_int64_t	num;

	if (argc != 2)

	/* okay, okay, u_quad_t may not be u_int64_t... */
	num = strtouq(*++argv, NULL, 0);
	printf("in network byte order: %qx\n", num);

As an aside, these three mailing lists may not actually be entirely
appropriate for this kind of vanilla computer question.

 == Roland Dowdeswell                      http://www.Imrryr.ORG/~elric/  ==
 == The Unofficial NetBSD Web Pages        http://www.Imrryr.ORG/NetBSD/  ==
 == The NetBSD Project                            http://www.NetBSD.ORG/  ==