comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Little tutorial about streams
Date: Tue, 1 Mar 2011 15:38:42 +0100
Date: 2011-03-01T15:38:42+01:00	[thread overview]
Message-ID: <1ppzt5sz6fzn5$.1p20pqy4on9bt.dlg@40tude.net> (raw)
In-Reply-To: m2mxlfvt9j.fsf@pushface.org

On Tue, 01 Mar 2011 13:56:40 +0000, Simon Wright wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
> 
>> You can also mention chain code as a technique to implement
>> S'Read/Write in a platform independent way.
>
> ?
> 
> Wikipedia says "A chain code is a lossless compression algorithm for
> monochrome images."

I guess this is because chain codes were initially deployed for encoding
pixels and directions (left, top-left etc) in image processing. But chain
code is useful for any encoding of variable-length data without an explicit
length count. E.g. UTF-8 is a chain code. 

Naturals of any length can be portably encoded using chain code like this:

0 = 16#00#
1 = 16#01#
127= 16#7F#
128= 16#80# 16#01# 
129= 16#81# 16#01#
... 

(assuming that octets are atomic). The high order bit when 0 indicates end
of the chain. The lower order bits encode the value.

Signed integer is encoded as above multiplied by 2 using the lowest bit for
the sign.

Floating point numbers are encoded as integer fraction (normalized,
multiplied by 2**p) followed by the integer normalized exponent - p. p is
the required precision.

Enumerations are encoded as E'Pos.

Strings are as the length and the body. (Nobody uses wide-strings of course
(:-)).

That basically is.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2011-03-01 14:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-28 17:00 Ann: Little tutorial about streams mockturtle
2011-02-28 20:32 ` Ludovic Brenta
2011-03-01  3:48 ` Randy Brukardt
2011-03-01  9:54   ` AdaMagica
2011-03-01 10:16   ` Dmitry A. Kazakov
2011-03-01 13:56     ` Simon Wright
2011-03-01 14:38       ` Dmitry A. Kazakov [this message]
2011-03-04 20:58         ` mockturtle
2011-03-05  1:08           ` Shark8
2011-03-05  1:35           ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox