MESSAGE
DATE | 2016-12-06 |
FROM | Christopher League
|
SUBJECT | Re: [Learn] png data format
|
From learn-bounces-at-nylxs.com Tue Dec 6 17:14:21 2016 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: from www.mrbrklyn.com (www.mrbrklyn.com [96.57.23.82]) by mrbrklyn.com (Postfix) with ESMTP id 1FA74161312; Tue, 6 Dec 2016 17:14:21 -0500 (EST) X-Original-To: learn-at-nylxs.com Delivered-To: learn-at-nylxs.com Received: from liucs.net (contrapunctus.net [174.136.110.10]) by mrbrklyn.com (Postfix) with ESMTP id D16D8160E77; Tue, 6 Dec 2016 17:14:17 -0500 (EST) Received: from localhost (pool-98-113-34-169.nycmny.fios.verizon.net [98.113.34.169]) by liucs.net (Postfix) with ESMTPSA id 06168E096; Tue, 6 Dec 2016 17:14:15 -0500 (EST) From: Christopher League To: Ruben Safir , Hangout , learn-at-nylxs.com In-Reply-To: References: <66105244-4afa-4330-b0c2-0661bde965fd-at-mrbrklyn.com> <87bmwpf857.fsf-at-contrapunctus.net> <878trtf7qw.fsf-at-contrapunctus.net> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/25.1.1 (x86_64-unknown-linux-gnu) Date: Tue, 06 Dec 2016 17:14:12 -0500 Message-ID: <87h96gemdn.fsf-at-contrapunctus.net> MIME-Version: 1.0 Subject: Re: [Learn] png data format X-BeenThere: learn-at-nylxs.com X-Mailman-Version: 2.1.17 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============2087657846==" Errors-To: learn-bounces-at-nylxs.com Sender: "Learn"
--===============2087657846== Content-Type: multipart/signed; boundary="===-=-="; micalg=pgp-sha256; protocol="application/pgp-signature"
--===-=-= Content-Type: multipart/mixed; boundary="=-=-="
--=-=-= Content-Type: multipart/alternative; boundary="==-=-="
--==-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable
Ruben Safir writes:
> There is an aspect of this I just don't understand. Why does the order > remain intact without ntohl when you look byte by byte through the > allocated memory, but the order is reversed when you evaluate it as a > continuous 32 bit unsigned int variable
Memory is essentially just an array of *bytes*, because memory is byte-addressable. The addressable unit is never smaller than a byte -- you can't have a pointer just to a bit or three.
And if you THINK have a pointer to something bigger than a byte, you REALLY DON'T. You STILL just have a pointer to a byte, but when you read from it we're going to also read the next several bytes.
So when you do that, the way that larger values (such as 32-bit integers) are stored as bytes MATTERS. And different machines do it differently. (BTW, historically there isn't just big- and little-endian, some machines used other alternatives that are often called "middle-endian"! Thank your $deity (if any) that those architectures are now extinct.)
I think this page helps:
CL
--==-=-= Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
1.0, user-scalable=3Dyes">
Ruben Safir ruben-at-mrbrklyn.com= writes:
There is an aspect of this I just don=E2=80=99t understand. Why does the= order remain intact without ntohl when you look byte by byte through the a= llocated memory, but the order is reversed when you evaluate it as a contin= uous 32 bit unsigned int variable
Memory is essentially just an array of bytes, because memory is= byte-addressable. The addressable unit is never smaller than a byte =E2=80= =93 you can=E2=80=99t have a pointer just to a bit or three.
And if you THINK have a pointer to something bigger than a byte, you REA= LLY DON=E2=80=99T. You STILL just have a pointer to a byte, but when you re= ad from it we=E2=80=99re going to also read the next several bytes.
So when you do that, the way that larger values (such as 32-bit integers= ) are stored as bytes MATTERS. And different machines do it differently. (B= TW, historically there isn=E2=80=99t just big- and little-endian, some mach= ines used other alternatives that are often called =E2=80=9Cmiddle-endian= =E2=80=9D! Thank your $deity (if any) that those architectures are now exti= nct.)
I think this page helps: /cmsc311/Notes/Data/endian.html" class=3D"uri">https://www.cs.umd.edu/class= /sum2003/cmsc311/Notes/Data/endian.html
CL
--==-=-=--
--=-=-=--
--===-=-= Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iQEzBAEBCAAdFiEE3x0LN7z09c1wuX58a4uzPU8xsIsFAlhHODQACgkQa4uzPU8x sIvpawf/WzV3UjKUqT8UtVDCAkSI0W0vRm6dzbDdtIlKTL64kx6kjk8vN85FqZWv giDREjbRwJ/vIjAEqF1gCAvhD8gM2x1JBaujx2SYjchejBHsgDYNFttCROpXxlKZ VqLSzC+rnHdn+/qxuHH86zvB+zQ4OJ7NlEGM7yEQrYVKhIclghS6QvOASentgxMZ jGqZDUDFY2zo3TVyogSg3YtXmve1kO+mofTd5RwEvPs1726Ld4UqKaFln7lgfYCK DKxIl19TuA/ByHNHW9UKsr/lip4dE1bP+4le98bLRWvHwQ9OnxAkaUOJGm0DJLvy K17nZTiiAhZ9NMD+6Fi6WEBN/TpK5A== =jDGh -----END PGP SIGNATURE----- --===-=-=--
--===============2087657846== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline
_______________________________________________ Learn mailing list Learn-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/learn
--===============2087657846==--
|
|