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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3ae40b42b99b8123 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!newsfeed.kamp.net!newsfeed.kamp.net!feeder.news-service.com!feeder3.cambriumusenet.nl!feeder1.cambriumusenet.nl!feed.tweaknews.nl!87.79.20.105.MISMATCH!news.netcologne.de!ramfeed1.netcologne.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Little tutorial about streams Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Tue, 1 Mar 2011 15:38:42 +0100 Message-ID: <1ppzt5sz6fzn5$.1p20pqy4on9bt.dlg@40tude.net> NNTP-Posting-Date: 01 Mar 2011 15:38:42 CET NNTP-Posting-Host: 202aeb4a.newsspool4.arcor-online.net X-Trace: DXC=K43TD3mORfS<<0iRN7DLEQ4IUK On Tue, 01 Mar 2011 13:56:40 +0000, Simon Wright wrote: > "Dmitry A. Kazakov" 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