From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,81bce7ee9133fb42 X-Google-Attributes: gid103376,public From: tore@lis.pitt.edu (Tore Joergensen) Subject: Re: GNAT Ada for DOS - Reading Integers Problem Date: 1996/02/24 Message-ID: <4gmded$rib@toads.pgh.pa.us>#1/1 X-Deja-AN: 140878671 references: <4g2efj$d5d@susscsc1.rdg.ac.uk> organization: University of Pittsburgh newsgroups: comp.lang.ada Date: 1996-02-24T00:00:00+00:00 List-Id: William Paul Berriss (strberis) wrote: [...snip...] : What it does is this: : When reading in the peppers.ras file it gets the nymbers form the header BUT : instead of 512 it shows (on the screen) 131072, and instead of 24 it shows : something huge like 6291456. All these 'wrong' numbers can be made from : other numbers, e.g. 131072 is 256 times 512. It should have been 512! : The image is fine, I can view it on PaintBrush for windows say. : Also, if I strip this header of 'huge' numbers and replace it with the : numbers 512 ,512, 24, 1 etc then when I read it in again I do get the correct : numbers, 512, 512 ,24, 1 etc. But then, of course? , PaintBrush cannot read : in the image. Obviously the numbers look 'funny' to IT ! [...snip...] What you have discovered is the little endian vs. big endian problem. You can read about it in Ada95-LRM:13.5.3. I'm not sure if gnat supports specifying the bit_order attribute or not, but there are simple solutions to fix it. One way to do it would be to define a 16 bit unsigned integer and use 'A := shift_left(A,8)+shift_right(A,8);' (see LRM:B.2). I guess somebody can tell you the best way to do it (if it isn't the above solution). -- +-------------------------+-------------------------------------------+ | Tore B. Joergensen | e-mail : tore@lis.pitt.edu | | Centre Court Villa | web : http://www.pitt.edu/~tojst1 | | 5535 Centre Avenue # 6 | | | Pgh, PA 15232, USA | Norwegian MSIS-student at Univ. of Pgh. | +-------------------------+-------------------------------------------+