Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the high part of physical address structure is defined as signed type?

Tags:

c

windows

I see some physical address structure is defined like this:

typedef union {
   struct {
       ULONG LowPart;
       LONG HighPart;
   } u;
   LONGLONG QuadPart;
} PHYSICAL_ADDRESS;

I don't understand why the high part is defined as signed type... Can anyone give an explanation?

like image 830
solotim Avatar asked Mar 02 '12 03:03

solotim


People also ask

What is the importance of storage socket address structure?

Various structures are used in Unix Socket Programming to hold information about the address and port, and other information. Most socket functions require a pointer to a socket address structure as an argument. Structures defined in this chapter are related to Internet Protocol Family.

What is socket address what is its structure in computer network?

A socket connecting to the network is created at each end of the communication. Each socket has a specific address. This address is composed of an IP address and a port number. Socket are generally employed in client server applications.

How do you identify a IPv4 socket address structure?

An IPv4 socket address structure, commonly called an "Internet socket address structure," is named sockaddr_in and is defined by including the <netinet/in. h> header.


1 Answers

The number is signed to make math on it make more sense. If you subtract the address 123 from 456, you expect to get the address 333, right? So if you subtract 456 from 123, you expect to get -333, not 18,446,744,073,709,551,283, right? That's why addresses are signed.

The reason only the high part is signed is that a number only has one sign bit, and it's always the highest (most-significant) bit.

like image 107
Gabe Avatar answered Oct 13 '22 08:10

Gabe