W3C home > Mailing lists > Public > public-expath@w3.org > March 2013

Packing/unpacking numeric data (Was: Re: Comments on binary specification)

From: Jirka Kosek <jirka@kosek.cz>
Date: Thu, 14 Mar 2013 10:31:49 +0100
Message-ID: <51419905.5050303@kosek.cz>
To: Michael Kay <mike@saxonica.com>
CC: public-expath@w3.org
On 13.3.2013 11:01, Michael Kay wrote:
> 7 - numeric data.
> 
> I wish there were a way of doing this with fewer functions. I think I'd
> be inclined to keep float and double, and replace all the integer ones with
> 
> unpack-signed-integer($in, $offset, $length) => integer
> unpack-unsigned-integer($in, $offset, $length) => integer

I have no problem with this simplification.

> pack-integer($in, $length)

Shouldn't we provide signed/unsigned variant here as well to catch
errors in input? For example suppose I want to serialize as signedByte
but by mistake I have value greater then 127 (largest positive value
representable in signedByte):

pack-integer(160, 1)

This will simply return octet 160 (0xA0) instead of raising error.

-- 
------------------------------------------------------------------
  Jirka Kosek      e-mail: jirka@kosek.cz      http://xmlguru.cz
------------------------------------------------------------------
       Professional XML consulting and training services
  DocBook customization, custom XSLT/XSL-FO document processing
------------------------------------------------------------------
 OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 rep.
------------------------------------------------------------------
    Bringing you XML Prague conference    http://xmlprague.cz
------------------------------------------------------------------


Received on Thursday, 14 March 2013 09:32:18 GMT

This archive was generated by hypermail 2.3.1 : Thursday, 14 March 2013 09:32:19 GMT