Re: [Cbor] Money amounts

Carsten Bormann <cabo@tzi.org> Wed, 27 February 2019 12:49 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id E5DC8128D52 for <cbor@ietfa.amsl.com>; Wed, 27 Feb 2019 04:49:25 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.199
X-Spam-Level:
X-Spam-Status: No, score=-4.199 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, URIBL_BLOCKED=0.001] autolearn=unavailable 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 hYDdUlxhSm5b for <cbor@ietfa.amsl.com>; Wed, 27 Feb 2019 04:49:25 -0800 (PST)
Received: from mailhost.informatik.uni-bremen.de (mailhost.informatik.uni-bremen.de [IPv6:2001:638:708:30c9::12]) (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 D6472130EB8 for <cbor@ietf.org>; Wed, 27 Feb 2019 04:49:24 -0800 (PST)
X-Virus-Scanned: amavisd-new at informatik.uni-bremen.de
Received: from submithost.informatik.uni-bremen.de (submithost2.informatik.uni-bremen.de [134.102.200.7]) by mailhost.informatik.uni-bremen.de (8.14.5/8.14.5) with ESMTP id x1RCnDMc009193; Wed, 27 Feb 2019 13:49:18 +0100 (CET)
Received: from [192.168.217.106] (p54A6C2FE.dip0.t-ipconnect.de [84.166.194.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by submithost.informatik.uni-bremen.de (Postfix) with ESMTPSA id 448b950JkLz1Br6; Wed, 27 Feb 2019 13:49:13 +0100 (CET)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <20190227134113.3dd82f19.changaco@changaco.oy.lc>
Date: Wed, 27 Feb 2019 13:49:12 +0100
Cc: "cbor@ietf.org" <cbor@ietf.org>
X-Mao-Original-Outgoing-Id: 572964550.4093111-337152b4041ec8dc6c3d83018f86f02c
Content-Transfer-Encoding: quoted-printable
Message-Id: <F266FE2A-0439-4B73-A5AA-1ABC1F8ABD17@tzi.org>
References: <20190225102821.583b57b9.changaco@changaco.oy.lc> <A996325B-9D87-4537-87B4-59CD40F56FF2@tzi.org> <20190225114418.5eaea1dd.changaco@changaco.oy.lc> <f2fde9b2c8f54d9691b0933e7818b90c@pdv-FS.de> <20190227134113.3dd82f19.changaco@changaco.oy.lc>
To: Changaco <changaco=40changaco.oy.lc@dmarc.ietf.org>
X-Mailer: Apple Mail (2.3445.9.1)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/S_KXRSVSXkoInnrkCRI59s3McOA>
Subject: Re: [Cbor] Money amounts
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 27 Feb 2019 12:49:26 -0000

On Feb 27, 2019, at 13:41, Changaco <changaco=40changaco.oy.lc@dmarc.ietf.org> wrote:
> 
> On Mon, 25 Feb 2019 11:06:57 +0000 Richter, Jörg wrote:
>> And I'm not a big fan of encoding additional information in the number of 
>> decimal places.  So "EUR10.00" should be transmitted as "EUR10", or ["EUR",10].
>> But for other decimal fractions you are right that the string might be shorter.
> 
> I think it's best to be lossless by default. If an encoder receives a `10.00`, for example a `Decimal('10.00')` object in Python, then it should encode the trailing zeroes unless it has been explicitly configured to drop them.

But that presumes there is a semantic difference between “EUR10” and “EUR10.00”.  Is there is there not?

Assuming there is no semantic difference, we could still make it so that an encoder can output both, and a decoder is required to be able to process both, presumably with an identical result.  Or we could use the concept of “preferred encoding” with that, with making the shortest encoding the preferred one, but not placing the onus on the encoder to always generate preferred encoding (outside instances of canonicalization), but continuing to place the onus on the decoder to handle both, but *not* placing the onus on it to keep the distinction available to the application.

Interoperably handling equivalent representations of the same information has turned out to be more laden with consequences than one would initially think…

If there *is* a semantic difference, it should be clearly explained, or even better, made more explicit in the encoding.

Grüße, Carsten