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

Kari Hurtta <hurtta-ietf@elmme-mailer.org> Wed, 29 January 2020 18:20 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 427A712085C for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Wed, 29 Jan 2020 10:20:23 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.65
X-Spam-Level:
X-Spam-Status: No, score=-2.65 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
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 e4_qQHYYFdRz for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Wed, 29 Jan 2020 10:20:20 -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 9D983120849 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Wed, 29 Jan 2020 10:20:20 -0800 (PST)
Received: from lists by frink.w3.org with local (Exim 4.89) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1iwruX-0001iB-Oy for ietf-http-wg-dist@listhub.w3.org; Wed, 29 Jan 2020 18:17:57 +0000
Resent-Date: Wed, 29 Jan 2020 18:17:57 +0000
Resent-Message-Id: <E1iwruX-0001iB-Oy@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 <khurtta@welho.com>) id 1iwruV-0001gf-N4 for ietf-http-wg@listhub.w3.org; Wed, 29 Jan 2020 18:17:55 +0000
Received: from welho-filter3.welho.com ([83.102.41.25]) by titan.w3.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <khurtta@welho.com>) id 1iwruT-0008JC-Hj for ietf-http-wg@w3.org; Wed, 29 Jan 2020 18:17:55 +0000
Received: from localhost (localhost [127.0.0.1]) by welho-filter3.welho.com (Postfix) with ESMTP id 78AF7350F; Wed, 29 Jan 2020 20:17:50 +0200 (EET)
X-Virus-Scanned: Debian amavisd-new at pp.htv.fi
Received: from welho-smtp2.welho.com ([IPv6:::ffff:83.102.41.85]) by localhost (welho-filter3.welho.com [::ffff:83.102.41.25]) (amavisd-new, port 10024) with ESMTP id ZSj2_8sNeihq; Wed, 29 Jan 2020 20:17:48 +0200 (EET)
Received: from kasvihuone.keh.iki.fi (89-27-39-95.bb.dnainternet.fi [89.27.39.95]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by welho-smtp2.welho.com (Postfix) with ESMTPS id DBB7B72; Wed, 29 Jan 2020 20:17:41 +0200 (EET)
In-Reply-To: <158028031175.4610.9085377324549619919@ietfa.amsl.com>
References: <158028031175.4610.9085377324549619919@ietfa.amsl.com>
To: HTTP Working Group <ietf-http-wg@w3.org>
Date: Wed, 29 Jan 2020 20:17:41 +0200
From: Kari Hurtta <hurtta-ietf@elmme-mailer.org>
CC: Kari Hurtta <hurtta-ietf@elmme-mailer.org>, Mark Nottingham <mnot@mnot.net>, Poul-Henning Kamp <phk@varnish-cache.org>
X-Mailer: ELM [version ME+ 2.5 PLalpha50+]
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="US-ASCII"
Message-Id: <20200129181750.78AF7350F@welho-filter3.welho.com>
Received-SPF: none client-ip=83.102.41.25; envelope-from=khurtta@welho.com; helo=welho-filter3.welho.com
X-W3C-Hub-Spam-Status: No, score=-5.3
X-W3C-Hub-Spam-Report: BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_NONE=0.001, W3C_AA=-1, W3C_IRA=-1, W3C_WL=-1
X-W3C-Scan-Sig: titan.w3.org 1iwruT-0008JC-Hj 85ca421e413837df1578c81cdb33e8ce
X-Original-To: ietf-http-wg@w3.org
Subject: draft-ietf-httpbis-header-structure-15, Serializing a Decimal
Archived-At: <https://www.w3.org/mid/20200129181750.78AF7350F@welho-filter3.welho.com>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/37315
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>

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