BIGENDIAN

Lowden, James K LowdenJK at bernstein.com
Wed Jul 11 13:23:36 EDT 2001


-----Original Message-----
From: Sam Sam [mailto:s4m at lycos.com]
Sent: July 11, 2001 12:49 PM

I subscribe to this mailing list since 1 years ago, and I always hear about
Bigendian problem, what is Bigendian anyways ?? 

Hi Sam, 

Fair question.  Maybe it should be in the docs, so I'll give you my first
draft.  I don't know where you're starting from, so my explanation is a
little longer than the others.  

BTW, a Google search will quickly locate copies of "The Jargon Dictionary",
which is a good source for general explanations.  Try for instance 
http://info.astrian.net/jargon/terms/b/big-endian.html

The number 512 (decimal) is 200 in hex and 1000000000 binary.  It takes two
bytes to represent in memory as an integer.  

Breaking that up into bytes, we have 02-00 and 00000010-00000000 

Intel processors are little endian, meaning they store integers "bottom up".
The low-order byte (00) gets the first address, and the high-order byte (02)
gets the next one.  If you declared a variable:

	int foo = 512;

and opened up the debugger, you'd find foo stored as 00 02.  

On a Sun box you'd see 20 00.  

Why does this matter to FreeTDS?  The database server lives on a hardware
architecture, of course, which might be either big- or little-endian.  So
does the client.  Somebody has to do the conversion, if conversion is
needed.  I'm a little fuzzy about who, though.  

I thought the client indicates its endianism to the server and expects the
server to reorganize things to the client's liking.  I thought that's what
broke dates on big-endian clients to MS servers until Microsoft's patch came
out.  But I know FreeTDS does some adjusting of its own (and has a little
more to do :-/ ).  

I hope that's clear.  

--jkl



More information about the FreeTDS mailing list