Re: [Cbor] Money amounts

Changaco <changaco@changaco.oy.lc> Mon, 25 February 2019 10:44 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 D6296130F35 for <cbor@ietfa.amsl.com>; Mon, 25 Feb 2019 02:44:25 -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 jexDzwwrh0Lf for <cbor@ietfa.amsl.com>; Mon, 25 Feb 2019 02:44:24 -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 C4C7A130F52 for <cbor@ietf.org>; Mon, 25 Feb 2019 02:44:22 -0800 (PST)
Received: from changaco.net (localhost [127.0.0.1]) by changaco.net (OpenSMTPD) with ESMTP id 9f44482b; Mon, 25 Feb 2019 10:44:20 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=changaco.oy.lc; h=date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s= changaco; bh=wfMHlatbpGx0GTLaFzJQKKn7iEs=; b=YDXWEDO5Hna9QNkjA16 hIEuXKYpLVtkmnXjcFcYFJ1qn/X2RWc3SGefW2xzps6CUlttYZvgIlaP7TicCXC4 uMP6dCv3RdO+2x9YPdLS2cztH1ZeIBdW3DAFAXjGqd/z3MuaTm3GAhKx3ihUJz+L 3Gtxp+WvgGSLmPveSXrW+qfg=
Received: by changaco.net (OpenSMTPD) with ESMTPSA id 1174a1a7 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Mon, 25 Feb 2019 10:44:20 +0000 (UTC)
Date: Mon, 25 Feb 2019 11:44:18 +0100
From: Changaco <changaco@changaco.oy.lc>
To: Carsten Bormann <cabo@tzi.org>
Cc: cbor@ietf.org
Message-ID: <20190225114418.5eaea1dd.changaco@changaco.oy.lc>
In-Reply-To: <A996325B-9D87-4537-87B4-59CD40F56FF2@tzi.org>
References: <20190225102821.583b57b9.changaco@changaco.oy.lc> <A996325B-9D87-4537-87B4-59CD40F56FF2@tzi.org>
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/ilSofqBpkxOu63KGEShgV2sCqaY>
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: Mon, 25 Feb 2019 10:44:32 -0000

On Mon, 25 Feb 2019 10:41:14 +0100 Carsten Bormann wrote:
> What is the difference between a 77112 basket with just one currency in it and a 77111 money?

We use baskets when summing amounts that *can* be in different currencies, but in fact there may only be one currency, or none at all, so the basket can end up containing only one currency or be completely empty.

I put an example of a basket with only one currency to show that it is valid.

> (I’m not a big fan of having to parse the string version of 77111, but if that string style is important to your application, that’s not relevant.)

It's not really important, I added it mostly because for some "small" amounts it can actually be shorter than other formats.

For example `"EUR10.00"` takes up 9 bytes whereas `["EUR", 10.00]` uses 11 bytes when the number is encoded as a decimal fraction (tag 4).

> You never have the use case of an alternative (like 77112, but “either pay USD 25 or EUR 20 or CAD 30 or AUD 35”)?

No.