* Re: OFF-TOPIC: little-endian vs. big-endian conversion
@ 1998-04-03 17:27 Greg Lindahl
1998-04-03 17:51 ` Michal Jaegermann
0 siblings, 1 reply; 7+ messages in thread
From: Greg Lindahl @ 1998-04-03 17:27 UTC (permalink / raw)
To: axp-list
> Hello all! I know this is off-topic, but I am getting desperate. I have
> some binary files that were generated on an sgi, but I need to read them
> on my Alpha (UDB with linux 2.0.20). I have learned that the sgi is
> big-endian, where the alpha is little-endian. The files are in the
> following format:
>
> 1 int followed by 52 doubles - repeated 20,000 times.
Is this an unformatted fortran file? In which case, the format is:
record length
data
repeat record length
On the SGI and Digital Unix, the record length is a 32 bit int. On the
latest f2c libraries, it's 64 bits. You have to account for this.
-- g
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: OFF-TOPIC: little-endian vs. big-endian conversion
1998-04-03 17:27 OFF-TOPIC: little-endian vs. big-endian conversion Greg Lindahl
@ 1998-04-03 17:51 ` Michal Jaegermann
0 siblings, 0 replies; 7+ messages in thread
From: Michal Jaegermann @ 1998-04-03 17:51 UTC (permalink / raw)
To: axp-list
>
> On the
> latest f2c libraries, it's 64 bits. You have to account for this.
It depends when they are coming from. If they are from the current g77
then f2c.h defines there, correctly I would argue, Fortran 'integer'
type as 'int' - i.e. 32 bits.
One has to be careful with that. An unfortunate result of living on a
"bleeding edge". Defining 'integer' as 'long' in headers which came with
'f2c' tranlator is a bug resulting likely from an attempt to acommodate
MS-DOS machines.
I would do such conversion in question in Perl anyway. You are working
too hard if you attempt to use anything else for the task. :-)
Michal
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: OFF-TOPIC: little-endian vs. big-endian conversion
@ 1998-04-03 17:54 Greg Lindahl
0 siblings, 0 replies; 7+ messages in thread
From: Greg Lindahl @ 1998-04-03 17:54 UTC (permalink / raw)
To: axp-list
> > On the
> > latest f2c libraries, it's 64 bits. You have to account for this.
>
> It depends when they are coming from. If they are from the current g77
> then f2c.h defines there, correctly I would argue, Fortran 'integer'
> type as 'int' - i.e. 32 bits.
The size of a Fortran integer is different from the size of the
Fortran record length. The latest g77 for alphas (egcs) has
these as 32 and 64 bits, respectively.
I think the record length size should be settable per-file at runtime,
but no one's done that yet.
-- g
^ permalink raw reply [flat|nested] 7+ messages in thread
* OFF-TOPIC: little-endian vs. big-endian conversion
@ 1998-04-03 17:15 Janice McCarthy
1998-04-03 17:33 ` Uncle George
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Janice McCarthy @ 1998-04-03 17:15 UTC (permalink / raw)
To: axp-list
Hello all! I know this is off-topic, but I am getting desperate. I have
some binary files that were generated on an sgi, but I need to read them
on my Alpha (UDB with linux 2.0.20). I have learned that the sgi is
big-endian, where the alpha is little-endian. The files are in the
following format:
1 int followed by 52 doubles - repeated 20,000 times.
I wrote a conversion program to reverse the bytes, but it doesn't seem to
work. Am I missing something? Is there more of a difference between the
two conventions? Can someone at least point me in the right direction?
There was at one time a mini-how-to, but it seems to have disappeared!
Thanks in advance,
Janice McCarthy
janice@acpub.duke.edu
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: OFF-TOPIC: little-endian vs. big-endian conversion
1998-04-03 17:15 Janice McCarthy
@ 1998-04-03 17:33 ` Uncle George
1998-04-03 17:54 ` Alvin Starr
1998-04-06 12:39 ` Mike Howard
2 siblings, 0 replies; 7+ messages in thread
From: Uncle George @ 1998-04-03 17:33 UTC (permalink / raw)
To: axp-list, Janice McCarthy
what does ur small pgm look like ? and r u sure that the floats/doubles are
the same ?
Janice McCarthy wrote:
> Hello all! I know this is off-topic, but I am getting desperate. I have
> some binary files that were generated on an sgi, but I need to read them
> on my Alpha (UDB with linux 2.0.20). I have learned that the sgi is
> big-endian, where the alpha is little-endian. The files are in the
> following format:
>
> 1 int followed by 52 doubles - repeated 20,000 times.
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: OFF-TOPIC: little-endian vs. big-endian conversion
1998-04-03 17:15 Janice McCarthy
1998-04-03 17:33 ` Uncle George
@ 1998-04-03 17:54 ` Alvin Starr
1998-04-06 12:39 ` Mike Howard
2 siblings, 0 replies; 7+ messages in thread
From: Alvin Starr @ 1998-04-03 17:54 UTC (permalink / raw)
To: Janice McCarthy; +Cc: axp-list
On Fri, 3 Apr 1998, Janice McCarthy wrote:
> Hello all! I know this is off-topic, but I am getting desperate. I have
> some binary files that were generated on an sgi, but I need to read them
> on my Alpha (UDB with linux 2.0.20). I have learned that the sgi is
> big-endian, where the alpha is little-endian. The files are in the
> following format:
>
> 1 int followed by 52 doubles - repeated 20,000 times.
Ints(32bit) should be swaped
1,2,3,4 => 4,3,2,1 in 4 byte chunks
If I remember correctly ieee is defined in a endian insensitive format.
That is you should be able to read it correctly on all machines. But it
has been a long time and I may have forgotten somthing.
If the doubles have to be swaped you should be swaping the order
1,2,3,4,5,6,7,8 => 8,7,6,5,4,3,2,1 in 8 byte chunks
Alvin Starr || voice: (416)493-3325
Interlink Connectivity || fax: (416)493-7974
alvin@iplink.net ||
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: OFF-TOPIC: little-endian vs. big-endian conversion
1998-04-03 17:15 Janice McCarthy
1998-04-03 17:33 ` Uncle George
1998-04-03 17:54 ` Alvin Starr
@ 1998-04-06 12:39 ` Mike Howard
2 siblings, 0 replies; 7+ messages in thread
From: Mike Howard @ 1998-04-06 12:39 UTC (permalink / raw)
To: axp-list; +Cc: clove1!mike
You can spend a lot of time on a problem like this. If you have control of the source of the data
or access to a similarly configured SGI machine, your best approach is to reformat the data [or
have it done] in ASCII.
Things are probably more standard than they used to be - with most supporting IEEE floating point -
but in the old days, in trying to do this type of thing I had to contend with:
1's complement versus 2's complement machines
15, 16, and 18 bit half word sizes
16, 32, 36, & 64 bit word sizes
30, 32, 36, 60, 64, & 72 bit floating point sizes
plethora's of floating point formats
for example: a floating point word consists of a characteristic and a mantissa.
Generally, the mantissa is a 1 or 2's complement integer or an unsigned integer which represents a
number between 1 and the smallest representable fraction or zero.
The characteristic is the exponent of an implied base which can be 2, 8, 16, 256, 10, or whatever
bright number the designer has chosen. It is an N bit number which represents a range of exponent
values between the largest and smallest possible ranges. Encodings I have seen are 1's and 2's
comlement and excess N - where N = 2^(width of exponent - 1) [treat the exponent as a signed number
and encode by adding N, so the encoded value is always positive].
This information is always tough to find - because no one needs it except compiler writers.
Generally it will be in the hardware architecture or assembler references for the machines in
question. Varian used to support several formats because they made both 16 and 18 bit machines.
If you really have to do this, you have my sympathy.
Mike Howard <mike@clove.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~1998-04-06 13:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-04-03 17:27 OFF-TOPIC: little-endian vs. big-endian conversion Greg Lindahl
1998-04-03 17:51 ` Michal Jaegermann
-- strict thread matches above, loose matches on Subject: below --
1998-04-03 17:54 Greg Lindahl
1998-04-03 17:15 Janice McCarthy
1998-04-03 17:33 ` Uncle George
1998-04-03 17:54 ` Alvin Starr
1998-04-06 12:39 ` Mike Howard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox