Re: draft-ietf-httpbis-header-structure-15, Serializing a Decimal

Mark Nottingham <mnot@mnot.net> Wed, 29 January 2020 22:23 UTC

Return-Path: <ietf-http-wg-request+bounce-httpbisa-archive-bis2juki=lists.ie@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 61B2212004E for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Wed, 29 Jan 2020 14:23:35 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.75
X-Spam-Level:
X-Spam-Status: No, score=-2.75 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=mnot.net header.b=K7AGXmKE; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=RnUuSVlZ
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ArRLaUuPIS1G for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Wed, 29 Jan 2020 14:23:33 -0800 (PST)
Received: from frink.w3.org (frink.w3.org [IPv6:2603:400a:ffff:804:801e:34:0:38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 6AE1012001B for <httpbisa-archive-bis2Juki@lists.ietf.org>; Wed, 29 Jan 2020 14:23:33 -0800 (PST)
Received: from lists by frink.w3.org with local (Exim 4.89) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1iwvip-0007gM-St for ietf-http-wg-dist@listhub.w3.org; Wed, 29 Jan 2020 22:22:07 +0000
Resent-Date: Wed, 29 Jan 2020 22:22:07 +0000
Resent-Message-Id: <E1iwvip-0007gM-St@frink.w3.org>
Received: from titan.w3.org ([2603:400a:ffff:804:801e:34:0:4c]) by frink.w3.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from <mnot@mnot.net>) id 1iwvio-0007fW-4Q for ietf-http-wg@listhub.w3.org; Wed, 29 Jan 2020 22:22:06 +0000
Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by titan.w3.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <mnot@mnot.net>) id 1iwvim-00073W-J1 for ietf-http-wg@w3.org; Wed, 29 Jan 2020 22:22:06 +0000
Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id A59EF21B03; Wed, 29 Jan 2020 17:22:01 -0500 (EST)
Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 29 Jan 2020 17:22:01 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mnot.net; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=fm1; bh=w ZprkQAhEDIyYNLULbtj9vTgjdm8zKcmfA14HyZaEOI=; b=K7AGXmKEbVWHnZuyr 1RLept3ZlpyzG3GTky6iuRlgWdrRNtl3k3MZX48Mghc8mVDyJo3ZM5/KLwjLVDeD cawHajbZZBjuhxtmaFv0OlEBrVrumSlEVIq4O1PqGqDj7VgbdxrAy81izJB6NtQP +kQz7a+JNU/Cdu99vYmoJ+WRr7gk0tiXBTqT7ZZd0OY8Y5zUKIx61plsbUJSbkTW gaOH6sqmviVdePRX7q7VNE5qXT4/kiOPoplSp3IU7w6ujv/RMY7pDiaX+shFoEVQ bbc7B37x5E5+mhuUevJ8SOdZwVezAqr5WMrNO119O3vqDcY39mVIdVWEreQcDSbX o10yw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=wZprkQAhEDIyYNLULbtj9vTgjdm8zKcmfA14HyZaE OI=; b=RnUuSVlZIMzLfXYl6UYydGAo38h08z9JYMr1BrkgWqUkQC3T9cB/BQiKi RmscyksECsWtJ74/BMDhZVDKtR5dmrMNtEk+OaTwIM8xrgL/8wIO5q4YU1bzjhfq HaKbJPFUs+QMxYId9vzu1zvyMY37dDIdBmrlaRFilDu/AuHSncXxI6JDjkgbXHze w1NCoK0bDbOyijZuYMD3NEm1KFMpbqVBPtmNNrYSun1DIOi/Tk6/ffQt0nAIHjAs Q7C/TWCGew3ucNoHUlLQl2kuiLHswKdBhLMKN96Fk44u4BZw3XA8iRfzSmz9+Umd srFGIYDStveSDI2NigtoAAN428+cw==
X-ME-Sender: <xms:iAUyXiP_zoz6jMy17mfs3DNMhvgH_YAsud670EWHFlqbi-x43kn8IQ>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrfeeigdduheejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurheptggguffhjgffgffkfhfvofesthhqmhdthhdtvdenucfhrhhomhepofgrrhhk ucfpohhtthhinhhghhgrmhcuoehmnhhothesmhhnohhtrdhnvghtqeenucffohhmrghinh epghhithhhuhgsrdgtohhmpdhivghtfhdrohhrghdpmhhnohhtrdhnvghtnecukfhppedu udelrddujedrudehkedrvdehudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehmnhhothesmhhnohhtrdhnvght
X-ME-Proxy: <xmx:iAUyXmeqKsI8ZDUc7z7QC8JtW0L7XFznI-Bn_tMtHXpn_iaQIMl9tA> <xmx:iAUyXoXpNZUCjSOJU7CIuv5UMcjxxA_zhJVef3s6DygFdz7nICbW4g> <xmx:iAUyXnD59l2a0i903qgVe70tEq6ucluKcmcNs9ZFlvKaZdCPrnceMA> <xmx:iQUyXjtadihOyw0I2KUl6dhyjeiMhicbvgJBr1BX9V9Zy2gFV2mWsw>
Received: from macbook-pro.mnot.net (unknown [119.17.158.251]) by mail.messagingengine.com (Postfix) with ESMTPA id E98E53060EF2; Wed, 29 Jan 2020 17:21:58 -0500 (EST)
Content-Type: text/plain; charset="us-ascii"
Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.40.2.2.4\))
From: Mark Nottingham <mnot@mnot.net>
In-Reply-To: <20200129181750.78AF7350F@welho-filter3.welho.com>
Date: Thu, 30 Jan 2020 09:21:56 +1100
Cc: HTTP Working Group <ietf-http-wg@w3.org>, Poul-Henning Kamp <phk@varnish-cache.org>
Content-Transfer-Encoding: quoted-printable
Message-Id: <9E4F45C3-1B74-458D-AE93-E6EA6BE58A9C@mnot.net>
References: <158028031175.4610.9085377324549619919@ietfa.amsl.com> <20200129181750.78AF7350F@welho-filter3.welho.com>
To: Kari Hurtta <hurtta-ietf@elmme-mailer.org>
X-Mailer: Apple Mail (2.3608.40.2.2.4)
Received-SPF: pass client-ip=66.111.4.26; envelope-from=mnot@mnot.net; helo=out2-smtp.messagingengine.com
X-W3C-Hub-Spam-Status: No, score=-9.8
X-W3C-Hub-Spam-Report: BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, W3C_AA=-1, W3C_DB=-1, W3C_IRA=-1, W3C_IRR=-3, W3C_WL=-1
X-W3C-Scan-Sig: titan.w3.org 1iwvim-00073W-J1 1b8e33f22bff43ae05d7d72b590f2125
X-Original-To: ietf-http-wg@w3.org
Subject: Re: draft-ietf-httpbis-header-structure-15, Serializing a Decimal
Archived-At: <https://www.w3.org/mid/9E4F45C3-1B74-458D-AE93-E6EA6BE58A9C@mnot.net>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/37322
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <https://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

Hi Kari,

Very good catch; I noticed this a while back but forgot to file an issue. Now:
  https://github.com/httpwg/http-extensions/issues/1043

Cheers,


> On 30 Jan 2020, at 5:17 am, Kari Hurtta <hurtta-ietf@elmme-mailer.org> wrote:
> 
> 4.1.5.  Serializing a Decimal
> https://tools.ietf.org/html/draft-ietf-httpbis-header-structure-15#section-4.1.5
> 
> 
> |   Given a decimal_number as input_decimal, return an ASCII string
> |   suitable for use in a HTTP header value.
> |
> |   1.  Let output be an empty string.
> |
> |   2.  If input_decimal is less than (but not equal to) 0, append "-" to
> |       output.
> |
> |   3.  Append input_decimal's integer component represented in base 10
> |       (using only decimal digits) to output; if it is zero, append "0".
> |
> |   4.  If the number of characters appended in the previous step is
> |       greater than 12, fail serialisation.
> |
> |   5.  Append "." to output.
> |
> |   6.  If input_decimal's fractional component is zero, append "0" to
> |       output.
> |
> |   7.  Else if input_decimal's fractional component has up to three
> |       digits, append them represented in base 10 (using only decimal
> |       digits) to output.
> |
> |   8.  Otherwise, append the first three digits of input_decimal's
> |       fractional component (represented in base 10, using only decimal
> |       digits) to output, rounding the final digit to the nearest value,
> |       or to the even value if it is equidistant.
> |
> |   9.  Return output.
> 
> I'm not sure how this works.
> 
> 
> Let's input_decimal  to be 123.9998
> 
> After step 3 output is "123"
> 
> After step 5 output is "123."
> 
> On step 8 the first three digits of input_decimal's fractional component
> are "999".
> 
> The final digit is "9".  There is no possiblity to round up that digit.
> 
> So final output is "123.999".
> 
> Is that orrect ? That is effectively truncation.
> 
> If 123.9998 is rounded to 3 fractional decimals, value is 124.000,
> but that serialization can not produce it.
> 
> / Kari Hurtta
> 
> 

--
Mark Nottingham   https://www.mnot.net/