|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
"Kenneth Brody" <kenbrody@spamcop.net> a écrit dans le message de news:
470BBAEF.94FC0D04@spamcop.net... > user923005 wrote: > [...] >> 20.9: How can I determine whether a machine's byte order is big- >> endian >> or little-endian? >> >> A: One way is to use a pointer: >> >> int x = 1; >> if(*(char *)&x == 1) >> printf("little-endian\n"); >> else printf("big-endian\n"); >> >> It's also possible to use a union. >> >> See also question 10.16. >> >> References: H&S Sec. 6.1.2 pp. 163-4. > > I supposed that, techincally, the answer is incomplete at best. > What happens on sizeof(char)==sizeof(int) systems? (And, on such > systems, is "endianness" even relevent?) > > Then there are systems with some horrible mixed-endianned storage, > where the 32-bit value 0x11223344 would be stored: 22 11 44 33. > (Or is it 33 44 11 22?) None still in production. You are refering to some PDP systems from more than 30 years ago. -- Chqrlie. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
"Charlie Gordon" <news@chqrlie.org> writes:
> "Kenneth Brody" <kenbrody@spamcop.net> a écrit dans le message de news: > 470BBAEF.94FC0D04@spamcop.net... [...] >> Then there are systems with some horrible mixed-endianned storage, >> where the 32-bit value 0x11223344 would be stored: 22 11 44 33. >> (Or is it 33 44 11 22?) > > None still in production. You are refering to some PDP systems from more > than 30 years ago. I'll bet there are still a few PDP-11s in production use. -- Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister" |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
"Keith Thompson" <kst-u@mib.org> a écrit dans le message de news:
ln7ilh1sl0.fsf@nuthaus.mib.org... > "Charlie Gordon" <news@chqrlie.org> writes: >> "Kenneth Brody" <kenbrody@spamcop.net> a écrit dans le message de news: >> 470BBAEF.94FC0D04@spamcop.net... > [...] >>> Then there are systems with some horrible mixed-endianned storage, >>> where the 32-bit value 0x11223344 would be stored: 22 11 44 33. >>> (Or is it 33 44 11 22?) >> >> None still in production. You are refering to some PDP systems from more >> than 30 years ago. > > I'll bet there are still a few PDP-11s in production use. Sorry, I meant none still being produced (manufactured) today. PDP-11s in working order are worth some money for museums and collectors ;-) -- Chqrlie. |
|
![]() |
| Outils de la discussion | |
|
|