From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,c1a55e8ae06d8e76 X-Google-Attributes: gid1164f8,public From: lionel@quark.enet.dec.com (Steve Lionel) Subject: Re: Representation of float on DEC-ALPHA Date: 1995/10/17 Message-ID: <460qt1$74s@zk2nws.zko.dec.com>#1/1 X-Deja-AN: 117677678 distribution: world references: <45thnl$klu@galadriel.iwb.mw.tu-muenchen.de> organization: Digital Equipment Corporation, Nashua NH reply-to: lionel@quark.enet.dec.com (Steve Lionel) newsgroups: comp.sys.dec In article <45thnl$klu@galadriel.iwb.mw.tu-muenchen.de>, rossgod@eowyn.iwb.mw.tu-muenchen.de (Ulrich Rossgoderer) writes: |>I've to read a binary file generated on a SGI or a HP workstation. The |>binary contains float numbers (single precision)? |> |>How do I read (convert) them on a DEC-ALPHA workstation? It can't be |>only done by byte swapping, because the following program [snip] |> |>produces the following output on a SGI: |>--------------------------------------- |> |>Please enter float number: 1.0 |>Byte 0: 63, Byte 1: 128, Byte 2: 0, Byte 4: 0 |> |>Please enter float number: -1.0 |>Byte 0: 191, Byte 1: 128, Byte 2: 0, Byte 4: 0 |> |>and on a DEC-ALPHA: |>------------------- |> |>Please enter float number: 1.0 |>Byte 0: 0, Byte 1: 0, Byte 2: -128, Byte 4: 63 |> |>Please enter float number: -1.0 |>Byte 0: 0, Byte 1: 0, Byte 2: -128, Byte 4: -65 If you look closer, you'd see that the Alpha values really are the "same" (except for byte ordering) as the SGI - on SGI, you're getting the values displayed as unsigned byte integers, whereas on Alpha they're signed bytes. (%d is supposed to be signed decimal, so I think the SGI results are wrong.) The bit patterns are the same (try using %x instead). -- Steve Lionel Mail: lionel@quark.enet.dec.com DEC Fortran Development WWW: http://www.digital.com/info/slionel.html Digital Equipment Corporation CompuServe: 75263,3001 110 Spit Brook Road, ZKO2-3/N30 Nashua, NH 03062-2698 "Free advice is worth every cent" For information on DEC Fortran 90, see http://www.digital.com/info/hpc/f90/