Avatar billede painelf Nybegynder
14. april 1999 - 00:00 Der er 9 kommentarer og
1 løsning

Indianer

Hvad er forskellen på big/little endian?
Avatar billede mr_white Nybegynder
14. april 1999 - 11:40 #1
Den store høvding siger at du måske kan fide et svar her:
http://www.debian.org/Lists-Archives/debian-user-9712/msg00064.html
Avatar billede painelf Nybegynder
14. april 1999 - 11:41 #2
Der står ikke noget om hvad det er.
Avatar billede mr_white Nybegynder
14. april 1999 - 11:51 #3
Ok ok ... Den store høvdings far siger at dette site måske er bedre:
http://www.cs.umass.edu/~verts/cs32/endian.html
Avatar billede painelf Nybegynder
14. april 1999 - 13:23 #4
Jeg kan ikke få kontakt til serveren!
Avatar billede mr_white Nybegynder
14. april 1999 - 13:36 #5
Jeg kan godt .. prøv igen
(eller kan jeg bare sige at det er et godt site .. tror jeg nok:)
Avatar billede painelf Nybegynder
14. april 1999 - 13:41 #6
Nej, jeg tror altså det har noget med tipi'er at gøre.
Avatar billede alfar Nybegynder
14. april 1999 - 15:22 #7
Hæhæ... Eitch Ti TiPi ? :o)
Avatar billede long Nybegynder
14. april 1999 - 21:32 #8
Her er der hvad der står på http://www.cs.umass.edu/~verts/cs32/endian.html


An Essay on Endian Order


Copyright (C) Dr. William T. Verts, April 19, 1996

Depending on which computing system you use, you will have to consider the byte order in
which multibyte numbers are stored, particularly when you are writing those numbers to a file.
The two orders are called "Little Endian" and "Big Endian".

The Basics

"Little Endian" means that the low-order byte of the number is stored in memory at the lowest
address, and the high-order byte at the highest address. (The little end comes first.) For
example, a 4 byte LongInt

    Byte3 Byte2 Byte1 Byte0

will be arranged in memory as follows:

    Base Address+0  Byte0
    Base Address+1  Byte1
    Base Address+2  Byte2
    Base Address+3  Byte3

Intel processors (those used in PC's) use "Little Endian" byte order.

"Big Endian" means that the high-order byte of the number is stored in memory at the lowest
address, and the low-order byte at the highest address. (The big end comes first.) Our
LongInt, would then be stored as:

    Base Address+0  Byte3
    Base Address+1  Byte2
    Base Address+2  Byte1
    Base Address+3  Byte0

Motorola processors (those used in Mac's) use "Big Endian" byte order.

Which is Better?

You may see a lot of discussion about the relative merits of the two formats, mostly religious
arguments based on the relative merits of the PC versus the Mac. Both formats have their
advantages and disadvantages.

In "Little Endian" form, assembly language instructions for picking up a 1, 2, 4, or longer byte
number proceed in exactly the same way for all formats: first pick up the lowest order byte at
offset 0. Also, because of the 1:1 relationship between address offset and byte number (offset
0 is byte 0), multiple precision math routines are correspondingly easy to write.

In "Big Endian" form, by having the high-order byte come first, you can always test whether
the number is positive or negative by looking at the byte at offset zero. You don't have to
know how long the number is, nor do you have to skip over any bytes to find the byte
containing the sign information. The numbers are also stored in the order in which they are
printed out, so binary to decimal routines are particularly efficient.

What does that Mean for Us?

What endian order means is that any time numbers are written to a file, you have to know how
the file is supposed to be constructed. If you write out a graphics file (such as a .BMP file) on
a machine with "Big Endian" integers, you must first reverse the byte order, or a "standard"
program to read your file won't work.

The Windows .BMP format, since it was developed on a "Little Endian" architecture, insists on
the "Little Endian" format. You must write your Save_BMP code this way, regardless of the
platform you are using.

Common file formats and their endian order are as follows:

    Adobe Photoshop -- Big Endian
    BMP (Windows and OS/2 Bitmaps) -- Little Endian
    DXF (AutoCad) -- Variable
    GIF -- Little Endian
    IMG (GEM Raster) -- Big Endian
    JPEG -- Big Endian
    FLI (Autodesk Animator) -- Little Endian
    MacPaint -- Big Endian
    PCX (PC Paintbrush) -- Little Endian
    PostScript -- Not Applicable (text!)
    POV (Persistence of Vision ray-tracer) -- Not Applicable (text!)
    QTM (Quicktime Movies) -- Little Endian (on a Mac!)
    Microsoft RIFF (.WAV & .AVI) -- Both
    Microsoft RTF (Rich Text Format) -- Little Endian
    SGI (Silicon Graphics) -- Big Endian
    Sun Raster -- Big Endian
    TGA (Targa) -- Little Endian
    TIFF -- Both, Endian identifier encoded into file
    WPG (WordPerfect Graphics Metafile) -- Big Endian (on a PC!)
    XWD (X Window Dump) -- Both, Endian identifier encoded into file

Correcting for the Non-Native Order

It is pretty easy to reverse a multibyte integer if you find you need the other format. A single
function can be used to switch from one to the other, in either direction. A simple and not very
efficient version might look as follows:

    Function Reverse (N:LongInt) : LongInt ;
    Var B0, B1, B2, B3 : Byte ;
    Begin
        B0 := N Mod 256 ;
        N  := N Div 256 ;
        B1 := N Mod 256 ;
        N  := N Div 256 ;
        B2 := N Mod 256 ;
        N  := N Div 256 ;
        B3 := N Mod 256 ;
        Reverse := (((B0 * 256 + B1) * 256 + B2) * 256 + B3) ;
    End ;

A more efficient version that depends on the presence of hexadecimal numbers, bit masking
operators AND, OR, and NOT, and shift operators SHL and SHR might look as follows:

    Function Reverse (N:LongInt) : LongInt ;
    Var B0, B1, B2, B3 : Byte ;
    Begin
        B0 := (N AND $000000FF) SHR  0 ;
        B1 := (N AND $0000FF00) SHR  8 ;
        B2 := (N AND $00FF0000) SHR 16 ;
        B3 := (N AND $FF000000) SHR 24 ;
        Reverse := (B0 SHL 24) OR (B1 SHL 16) OR (B2 SHL 8) OR (B3 SHL 0) ;
    End ;

There are certainly more efficient methods, some of which are quite machine and platform
dependent. Use what works best.
Avatar billede mr_white Nybegynder
19. april 1999 - 18:39 #9
Der er rentfaktisk optil flere forskelle på små og store indianere.
Fx kan den store indianer have sit eget private telt (også kaldet TiPi) hvor imod den lille indianer ofte vil være henvist til at samleve med evt. andre små indianere.
Oftes vil det også være muligt at opsavere store indidanere som er iført flere fjer end den genneralle (eller gennemsnitlige) lille indianer normalt vil bevære sig rundt i i fuld offentlighed, da hans status ofte ikke tillader dette.

Samtidig må vi her konkludere at hverken den lille eller store indianer er en fugl.

ps. Det er ofte set at den lille indianer vil tabe til den store indianer i tisse konkurancer (hvor der vægtes på højde (evt. op af nærmeste væg, tipi eller totempæl.))


Håber du kunne bruge svaret til noget.

Venlighilsen
  Hvid

pps. der findes to slaks geddar...
Rare gedder og knap så rare geddar!!!
Avatar billede painelf Nybegynder
19. april 1999 - 18:41 #10
Nu gi'r det hele jo mening! Tak for det!
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
IT-kurser om Microsoft 365, sikkerhed, personlig vækst, udvikling, digital markedsføring, grafisk design, SAP og forretningsanalyse.

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester