From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <t.lamprecht@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 5F4FA638AC
 for <pve-devel@lists.proxmox.com>; Wed, 26 Jan 2022 12:03:54 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 3EE186FC9
 for <pve-devel@lists.proxmox.com>; Wed, 26 Jan 2022 12:03:24 +0100 (CET)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 739A26FBE
 for <pve-devel@lists.proxmox.com>; Wed, 26 Jan 2022 12:03:23 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 4F4A4409EB
 for <pve-devel@lists.proxmox.com>; Wed, 26 Jan 2022 12:03:23 +0100 (CET)
Message-ID: <0049a5d0-55a9-2677-d251-0e37df3c56fc@proxmox.com>
Date: Wed, 26 Jan 2022 12:03:22 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101
 Thunderbird/97.0
Content-Language: en-US
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Stoiko Ivanov <s.ivanov@proxmox.com>
References: <20220125130443.1163977-1-s.ivanov@proxmox.com>
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
In-Reply-To: <20220125130443.1163977-1-s.ivanov@proxmox.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.057 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [proxmox.com]
Subject: [pve-devel] applied: [PATCH installer] get_device_desc: display
 disk size with 2 decimal places
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Wed, 26 Jan 2022 11:03:54 -0000

On 25.01.22 14:04, Stoiko Ivanov wrote:
> instead of cutting it off by using int
> 
> especially relevant currently with 2 TB disks (people wonder why
> it's displayed as 1 TiB - and would be fine with 1.95TiB).
> 
> Reported in our community forum:
> https://forum.proxmox.com/threads/.103636/
> 
> Tested in a VM with a 100 GiB, 20GiB and 2TiB disk
> 
> Addtionally added the explicit return ath the end of the if branch,
> instead of relying on the last statement not moving.
> 
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
> Alternatively we could also use sprintf without decimal places for rounding
> (Math::Round is a debian package of it's own) - if people consider
> 20.00GiB to not look too pleasing

In general I really do not find that too pleasing, but here I think that first,
knowing the cheapness of HW vendors and TB vs TiB exact sizes won't happen often
and second, keeping it simple in the installer has quite some merit, so your
solutions works fine for me here.

> 
> Thanks to Dominik for insisting to see the code on this and suggesting
> to actually improve it :)
> 
>  proxinstall | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
>

applied, thanks!