From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Simon Pugnet Newsgroups: gmane.emacs.help Subject: Re: Using Calc unit conversion functions in an Org Spreadsheet Date: Fri, 17 Nov 2023 07:36:45 +0000 Message-ID: <87il60al0y.fsf@polaris64.net> References: <87msvfp9p1.fsf@polaris64.net> <87zfze2m4d.fsf@web.de> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16890"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Michael Heerdegen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 17 08:37:44 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r3tQ7-0004GF-LP for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 17 Nov 2023 08:37:43 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r3tPN-00014a-26; Fri, 17 Nov 2023 02:36:57 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r3tPL-0000wU-20 for help-gnu-emacs@gnu.org; Fri, 17 Nov 2023 02:36:55 -0500 Original-Received: from mout-p-102.mailbox.org ([2001:67c:2050:0:465::102]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1r3tPJ-0003Vp-3n for help-gnu-emacs@gnu.org; Fri, 17 Nov 2023 02:36:54 -0500 Original-Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4SWpcv0rc3z9sSk; Fri, 17 Nov 2023 08:36:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polaris64.net; s=MBO0001; t=1700206607; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=CARoZgFOnrdw7uUXQZIZzf3KUTX5DDHzo+OUIfKwfBk=; b=wX4suRWUp+adNOFhz904j8gFI4bWz7nVZfnuhmn2GY0RC3boWAMS/Wg0Cp6g3sYd06nNxQ tSHwFhm6dxjGJj129i7MIVCqutDvljEAfJzm4+vKvuaRGxXS41HUgTfAnYoGVzH0yKdA8A Hq1OOyiLTbN1iRg81dG+SHsvcgtYMGYZt8KrBQKxENkEGhZhZ+x4BcL4MUZf3UR9cvdObM tK+l0tN/aiYgJjfhNGgAT0hUgwqj3WX3KW7MwPuQncyyJ/umO4n5tV6+E1QUpzQWj/Unq7 bw8oW0cUo6TufSVksC4bLdrcysbGWRjhJVVcclHmEYo9LcGCZJA3HDzq8/NSdA== In-Reply-To: <87zfze2m4d.fsf@web.de> (Michael Heerdegen's message of "Thu, 16 Nov 2023 08:28:02 +0100") X-Rspamd-Queue-Id: 4SWpcv0rc3z9sSk Received-SPF: pass client-ip=2001:67c:2050:0:465::102; envelope-from=simon@polaris64.net; helo=mout-p-102.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:145552 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Michael Heerdegen writes: > Simon Pugnet writes: > >> I found ~math-convert-units~ which seems to do exactly what I need >> however I can't get it to work and it's not documented. Passing a >> string expression such as ~(math-convert-units "45 min" 'hr)~ causes >> the error "Lisp error: (wrong-type-argument number-or-marker-p hr)". > > Hmm - yes, this function expects to be called like this (the example > converts 0.35 hr to 21 min): > > (math-convert-units > '(* (float 35 -1) (var hr var-hr)) > '(var min var-min)) >=20=20=20 > =3D=3D> (* (float 21 1) (var min var-min)) > > Unless you want to convert your input into the internal format of math > expressions, maybe it is easier to first divide the input by 1hr, then > simplify the (now unitless) result, and continue with that? > > Michael. Thanks Michael, yes I think as you say the easiest way is to remove the units first, then explicitly convert back to the desired units afterwards. Thanks for the explanation of math-convert-units. Once I saw it I became convinced that this was the best way to achieve my goals, but the alternative of using math operations to modify the units seems cleaner. Thanks for your help! Kind regards, Simon --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJIBAEBCAAyFiEEO/eF3hYsAMj7Tab9uhNZqCwLPvkFAmVXGA0UHHNpbW9uQHBv bGFyaXM2NC5uZXQACgkQuhNZqCwLPvlObw/+M5V3dVou1Ty/4lVkzOdPUhzLv/rP dykwcvGGxXqrxrPE1KN6p+5UXjifhR8vwgDUL8QNf+sAIvlP1NYYfhqK42h7qu9C aYE5qY2F3E8ACodE6i0T6F+9BRthFKGl9eLuT+AVImso36UDPVRWB3djQWaSDvFo e62lFNgSY/zQA6OTaXHVxV57oFM5B+MI0hGkyG1fnuJUpsq0ACQ7FW6leCjWcG1p TsaGK9jiV2tMYaUhQNK8SDqr441QDl7OkN3KpAVd/oGA3gFZLhIuUqq3+Z0he4O0 i3XCDWQK+XVbw2htEftSJuNI1Nj6OonPRrxr08WCTaXZuaILlCWMIbWY7ISUYiVn hQC3AQ5w+VBzBkF8U7hbVzCvsGh0lxEld4eHUj2OPSKZPsVeog8xoip3mAW0Q5hT EQwbBa7TXCQR22IBFNgWnhgGnwXUo6+81ViTs+M0pk8czs8Qp1UrsYQyCp4BOa+i g4gGkugTCxbZ/MKeAVUSyK3+Db6bO/HjdmVzGKNWJ782vx5ojtwwmU0UDuQSFOXg 6eo1XZ7y4kOJpsDUWsvaP/ybdaW2MA0Mu/qWO0f8gixlDOIpvriC7VTEtEycuvZR EY90LXUEG/vpKv1msAvlTyyww25MVN+27MV87lKyXpA1Vrr+apfUgwVOgzaUP7V+ QqLGZ9biklTzlus= =wC0i -----END PGP SIGNATURE----- --=-=-=--