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

Mark Nottingham <mnot@mnot.net> Thu, 30 January 2020 05:58 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 B611A12006B for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Wed, 29 Jan 2020 21:58:00 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.751
X-Spam-Level:
X-Spam-Status: No, score=-2.751 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] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=mnot.net header.b=YTXz6xod; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=irWD7MRr
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 48CQd0GdENyf for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Wed, 29 Jan 2020 21:57:58 -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 B6BF6120059 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Wed, 29 Jan 2020 21:57:58 -0800 (PST)
Received: from lists by frink.w3.org with local (Exim 4.89) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1ix2oO-0005NN-QG for ietf-http-wg-dist@listhub.w3.org; Thu, 30 Jan 2020 05:56:20 +0000
Resent-Date: Thu, 30 Jan 2020 05:56:20 +0000
Resent-Message-Id: <E1ix2oO-0005NN-QG@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 1ix2oM-0005MX-UT for ietf-http-wg@listhub.w3.org; Thu, 30 Jan 2020 05:56:18 +0000
Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by titan.w3.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <mnot@mnot.net>) id 1ix2oK-0000CO-L4 for ietf-http-wg@w3.org; Thu, 30 Jan 2020 05:56:18 +0000
Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 2AC3F4C1; Thu, 30 Jan 2020 00:56:12 -0500 (EST)
Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 30 Jan 2020 00:56:12 -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=Q MqUnMxWn/yrUIpP/2YNFtDoq5U5QXTP9jQnV19t5O0=; b=YTXz6xodFNPjVD9s8 +VTL+RE6OEWugL1ihnwuhx4nvZhgUyFgWCWlHHPhE1J5fxLOjAKRez74HSRznCbA oK0u3SBggmSPYBOMn2E2Z1F7obdMtNgFKx2NglQVFEoVDy5Rk573C5PNDwuHB9Ax L6HUSZOiAPzjWZY4fUIQLuD2yCMQxwg/1c58Flhzt8mRjUx7+HirDwRzRn0iaNwN s7A9A11xEJyITIgJ1UrIUFFOmaf+j6FaWkuSrOCEbBfln+Ihxf1aS2zQKzfPTLv2 ITfpcSKces75YiVOqOAx02/dg4XgB4t8sz3cSUCOUBB4ec1XbHTOL/Kb9RJisdsX pH7jQ==
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=QMqUnMxWn/yrUIpP/2YNFtDoq5U5QXTP9jQnV19t5 O0=; b=irWD7MRrIHDLJLrNU6LnISt3ixXvWeg/PZFceCynSAzZ8vJhxplM3HnIr 40UQ1wWOLvNHnv7f+u5rLWea9Zbj9T41IqJ5CCD4oSrGL16Gq68hTvPsPr6iZccV bF7F/KCJFFq2JQRwYd/dnwkmLHkEMFRgtqomF3cSmYx292K1f7jK6wLusEXBulCk m2quDHP9+PGX+ydbyL1hOeeI11RggYVnwWKeCKuzhuN6W+nAduk0kGRPlxbcQdDr U0Hoq3NNrUU1/C/mf+iDC0ox9KYsjg3nn5Q0aXDLU1oHLHItqseigWiEieA7taX0 ga57JppSX3gDG+24t2YFnmBZyV8WA==
X-ME-Sender: <xms:-m8yXvoK1zi26xINCDLXP9Kmuv6F9XK-z_-xISg3fLDyf0KFA9C5GQ>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrfeejgdekhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpegtggfuhfgjfffgkfhfvffosehtqhhmtdhhtddvnecuhfhrohhmpeforghrkhcu pfhothhtihhnghhhrghmuceomhhnohhtsehmnhhothdrnhgvtheqnecuffhomhgrihhnpe hgihhthhhusgdrtghomhdpihgvthhfrdhorhhgpdhmnhhothdrnhgvthenucfkphepuddu ledrudejrdduheekrddvhedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepmhhnohhtsehmnhhothdrnhgvth
X-ME-Proxy: <xmx:-m8yXgNSimcMfocXsFX4uobTIqoBTmpvSnFvGZMCPz_fRcPTUqImgA> <xmx:-m8yXt76OqUemy4hqyw7onIBTiJTFePYo_qkKM6hjxjP7DZvJqDZaQ> <xmx:-m8yXsWWF9I0nmYSCbCwG8cRcIyvIZldHCr2Gicamp9kfKVkZCuP2w> <xmx:-28yXjwVo_UxOae0sEY25_I73Y_bdT_HS5jJK5SQmU64P0m43aqMjg>
Received: from macbook-pro.mnot.net (unknown [119.17.158.251]) by mail.messagingengine.com (Postfix) with ESMTPA id 5D5653060BE4; Thu, 30 Jan 2020 00:56:09 -0500 (EST)
Content-Type: text/plain; charset="us-ascii"
Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\))
From: Mark Nottingham <mnot@mnot.net>
In-Reply-To: <20200130055238.1CFF91F35@welho-filter3.welho.com>
Date: Thu, 30 Jan 2020 16:56:06 +1100
Cc: HTTP Working Group <ietf-http-wg@w3.org>, Poul-Henning Kamp <phk@varnish-cache.org>
Content-Transfer-Encoding: quoted-printable
Message-Id: <3EBFAF31-4A2D-4154-8307-19FD49558213@mnot.net>
References: <158028031175.4610.9085377324549619919@ietfa.amsl.com> <20200129181750.78AF7350F@welho-filter3.welho.com> <9E4F45C3-1B74-458D-AE93-E6EA6BE58A9C@mnot.net> <20200130055238.1CFF91F35@welho-filter3.welho.com>
To: Kari Hurtta <hurtta-ietf@elmme-mailer.org>
X-Mailer: Apple Mail (2.3608.60.0.2.5)
Received-SPF: pass client-ip=64.147.123.25; envelope-from=mnot@mnot.net; helo=wout2-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, 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 1ix2oK-0000CO-L4 6fa994788688218c08a1a2c0710a8366
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/3EBFAF31-4A2D-4154-8307-19FD49558213@mnot.net>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/37328
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>

On 30 Jan 2020, at 4:52 pm, Kari Hurtta <hurtta-ietf@elmme-mailer.org> wrote:
> 
>> 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
> 
> | ... still isn't right, as Kari noticed. E.g., a value of 1.9944 won't get rounded to 2.0.
> 
> You mean:  E.g., a value of 1.9998  won't get rounded to 2.0.
> 
> Algorithm produces  three digits for fractional component.
> 
> And 1.994 is correct rounding for 1.9944, I think.

Corrected.

> 
> 
>> Cheers,
>> 
> 
> Another thing what can be issue when rounding is applied.
> 
>>> 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.
> 
> A decimal_number  number can be  -999 999 999 999.9997 or 999 999 999 999.9997
> 
> In step 3 there is  digits 999999999999 so no failure on step 4
> 
> 
>>> |   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.
> 
> First theree digits for fractional component are 999
> 
> "Correct" rounding for  -999 999 999 999.9997  is -1 000 000 000 000.0 and
> for 999 999 999 999.9997 is 1 000 000 000 000.0, but there are 13 digits 
> on integer component.
> 
> That is "solved" if 
> when decimal_number < -999 999 999 999.999 or
> decimal_number > 999 999 999 999.999, fractional component
> is truncated to 3 digits and rounding is not tried.
> 
> / Kari Hurtta

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