Re: [Cbor] Money amounts

Changaco <changaco@changaco.oy.lc> Wed, 27 February 2019 12:41 UTC

Return-Path: <changaco@changaco.oy.lc>
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 B8C13130EB8 for <cbor@ietfa.amsl.com>; Wed, 27 Feb 2019 04:41:22 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.001
X-Spam-Level:
X-Spam-Status: No, score=-2.001 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=changaco.oy.lc
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 sLshf8A-49Nz for <cbor@ietfa.amsl.com>; Wed, 27 Feb 2019 04:41:19 -0800 (PST)
Received: from changaco.net (changaco.net [5.135.153.125]) (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 CB621130EC5 for <cbor@ietf.org>; Wed, 27 Feb 2019 04:41:18 -0800 (PST)
Received: from changaco.net (localhost [127.0.0.1]) by changaco.net (OpenSMTPD) with ESMTP id 3bef7360 for <cbor@ietf.org>; Wed, 27 Feb 2019 12:41:15 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=changaco.oy.lc; h=date :from:to:subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=changaco; bh=0t8U0rT4 lNcFoJnlTw5+b+m8Bg8=; b=kJ0zEbyFUuI/OKbIMydDmdn4Iwz2s4d15VgcohB8 wlG5xdSTKtaUz+nTED97F9okhwKcJMmmOWWO+Mrb1KNnT13QN2oK9m/DReyZxUdx hyzHGnKbRvQjSdfY7FJd3OCCp9l/6jV+FYSsLbSxXU6ZCnOsrTUbcf0kDHpbB+7P vyQ=
Received: by changaco.net (OpenSMTPD) with ESMTPSA id 20b93922 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO) for <cbor@ietf.org>; Wed, 27 Feb 2019 12:41:15 +0000 (UTC)
Date: Wed, 27 Feb 2019 13:41:13 +0100
From: Changaco <changaco@changaco.oy.lc>
To: "cbor@ietf.org" <cbor@ietf.org>
Message-ID: <20190227134113.3dd82f19.changaco@changaco.oy.lc>
In-Reply-To: <f2fde9b2c8f54d9691b0933e7818b90c@pdv-FS.de>
References: <20190225102821.583b57b9.changaco@changaco.oy.lc> <A996325B-9D87-4537-87B4-59CD40F56FF2@tzi.org> <20190225114418.5eaea1dd.changaco@changaco.oy.lc> <f2fde9b2c8f54d9691b0933e7818b90c@pdv-FS.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/JxrM16fPcyg9a4O_XF6EBpoQJ6M>
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:41:23 -0000

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.

> Isn't this a use case for the additional attributes map?  To encode the 
> number of decimal places that should be used (e.g. for display).  What
> other applications do you have in mind for the attribute map?
> Can some common attributes be included in the proposal?

So far I've only used the attributes map to store a `fuzzy` flag, like the example I put in the spec. When that flag is on the messages we display to users mention that the amount is approximate.