Skip to Content.
Sympa Menu

freetds - RE: money wire format

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT schemamania.org>
  • To: "TDS Development Group" <freetds AT franklin.metalab.unc.edu>
  • Subject: RE: money wire format
  • Date: Wed, 7 Aug 2002 20:59:12 -0400


On Wed, 7 Aug 2002 23:13:11 +0100, "Thompson, Bill D (London)"
<ThompBil AT exchange.uk.ml.com> wrote:

> On a big endian machine the two 4 byte integers, strung together , can
> be treated as a single entity.
> On little endian of course they cannot.

Of course? I guess I don't understand what "strung together" means. :)
We can do 64-bit integer math. Does that count?

> Assuming we dont change tds_process_row,

But we probably should ...

> and the money value comes down
> unchanged the bytes would have to be moved as follows ( I reckon, and it
> IS late here )
>
> Wire:
>
> 1 2 3 4 5 6 7 8
>
> To:
>
> 5 6 7 8 1 2 3 4
>
> does that make sense ?

Thanks, Bill. It makes sense, except that I was expecting:

8 7 6 5 4 3 2 1

(assuming each digit represents one byte). That's what you get with:

char buf[] = "12345678";
int i = tds_swap_bytes( buf, 8 );
printf( "%d bytes swapped: \"%s\"\n", i, buf );

I also experimented with ntohl and htonl, program below. The output:

$ gcc -g -o swaptest swaptest.c
$ ./swaptest
8 bytes input: "12345678"
8 bytes swapped: "87654321"
8 bytes reverted: "12345678"

ntohl, input: "1234"
ntohl, output: "4321"
htonl, output: "1234"

I wonder what "htonll" would do?

I'll mangle a few and see how it goes.







Archive powered by MHonArc 2.6.24.

Top of Page