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

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 UTC