From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?Windows-1252?Q?Vincent_Bela=EFche?= Newsgroups: gmane.emacs.devel Subject: RE: using ses programatically (was: a ses question) Date: Sun, 19 Nov 2023 23:24:31 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_PAXP192MB1608F05F8AF80275F28338B884B5APAXP192MB1608EURP_" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22814"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel , "boruch_baum@gmx.com" To: =?Windows-1252?Q?andr=E9s_ram=EDrez?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Nov 20 04:21:09 2023 Return-path: Envelope-to: ged-emacs-devel@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 1r4uqT-0005h6-1z for ged-emacs-devel@m.gmane-mx.org; Mon, 20 Nov 2023 04:21:09 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r4upp-0004yK-Pw; Sun, 19 Nov 2023 22:20:29 -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 1r4r9a-0004A2-Gl for emacs-devel@gnu.org; Sun, 19 Nov 2023 18:24:38 -0500 Original-Received: from mail-vi1eur05olkn2035.outbound.protection.outlook.com ([40.92.90.35] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r4r9X-0007NG-MZ for emacs-devel@gnu.org; Sun, 19 Nov 2023 18:24:37 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gcx3Nnmyg4+d9OOHenlDxfbkE3mCR/k/r5tGB7MkvctIEpr5VhvUBQQ9bw+DYG/h6SuLwH5UU12loQwP2BE+0LtpPF7NYynvcYiWv8X0bPrAqqf9gxsudB6JMkeT7F5XmRjw1UMn6E9Ird5gQKgZTFMVB2ByeB/6OnHyhWky5Nd2xMZkoqySnk/RbR3ERq/O1kstlcKiVGb4blzmneVpuWaAWQlHbhehzyoqlsHli3gJ+kqoCq2hE2MoIRV3YhL/4/63UGKKBPOKBuS6RLN9QGgo0pkcDkZ9ZIcHq+Z7MSFH5mfjaDhOtTpJNaN92P/DBovHv29LmRy9x3BbsxO8Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eR2bo2HDckj124ejCErFFQ6uRjkIi8HYenQyS4gg53A=; b=HbN8ri5VgOaAA5705DPwpA79WzkskEbb9Of/65F0awg2Nz/fAVDKYmB5FxGuTY/g7qvCDI8W0klENW2r4hfxbq/Xale+hQ1xZmiFLR3XmbiJQwgKfgv9aDZxiDaNk4Xhw6e8hI7+5cisUjNAsso1FnoQDg9MsCgzVAjS46uoE6qEtpogiFLZ3rCFRST8NipwzmGaBLAs3EVgoY+w+p5jQZ2Up0iKfKiTAKnqDHnpDzc2DOtShbFlMwoRIkDDCgYNXFiNBTOQwMkne4+a3GJ4Tzsu7Umk0hvhSOqMgmZ6/3vSRSbSdDIAu9pMLOdebzmNqxeDNx4oX5UbO0FvovT3lQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Original-Received: from PAXP192MB1608.EURP192.PROD.OUTLOOK.COM (2603:10a6:102:28c::22) by DU0P192MB1866.EURP192.PROD.OUTLOOK.COM (2603:10a6:10:3b2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.26; Sun, 19 Nov 2023 23:24:32 +0000 Original-Received: from PAXP192MB1608.EURP192.PROD.OUTLOOK.COM ([fe80::d4fd:99e8:e147:9752]) by PAXP192MB1608.EURP192.PROD.OUTLOOK.COM ([fe80::d4fd:99e8:e147:9752%5]) with mapi id 15.20.7002.026; Sun, 19 Nov 2023 23:24:31 +0000 Thread-Topic: using ses programatically (was: a ses question) Thread-Index: AQHaDyaIFxl+uTQAXkSovHGVyH2ZGrBrhKoNgABOFwCAAB8A5YAALdsAgBSj6giAAVoZAIAAPkBXgAADb8E= In-Reply-To: Accept-Language: fr-FR, en-US Content-Language: fr-FR x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [AtoEnsLoiXhdm4Oe3eTDHjxiuyv5oGCf] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PAXP192MB1608:EE_|DU0P192MB1866:EE_ x-ms-office365-filtering-correlation-id: 0e835260-b15b-4222-9c48-08dbe956af37 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: GMT6CEkYz95c4ofQwwRArenp8gBrsJdYwo3Jj5z2JuaQBfRiwvqzBLMvWQ4PcPxaN5uld3fkYEuaClzVwDxG9wb558N20naPvFAFRBoGzCiRKk/Nn99LOew1BkdPpfgQEEcb8dn8mE4cuedmutqOv5UMFq20QE0YeAYCfAQUL2XTRka1VCdyfhmha4wbNFeJcit4QUxp8uPHnlSkJKJr2+s57EIz0azHwTPvA0SDkDTiMvvOMVN6FeXu0PRa30SmQm9uOy6mbharTHTZxlklYH9KFpT/al+fEeb0q2fSpyItPbF4GzfJ+9VK2ZHEpPqoXs1LMN1hPOxWWiM7/jY3TQDI4gYt7ZE/FSh8S+QqnmK8747gzs90JREjj+e28yBb9jvN25somhqcLjtRjNbQ6KD+1W5iMg8pNM/UzexXYdc64MnjNvzms1wLQ8KPK1N7zviFNXQ2RWk1vQnot5GD/Ow4AhKpdoZWWUAzo5q9j5zo6Jox5bo0JjA3dQHsJ/BBaR0bmxJpbeCf462jqYORwarRvNu+zT/8MIgUph/atAkV44gK3kzkMvC5U7Af+/bq x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?Windows-1252?Q?p/e+77HTKIzyXFpTR9XFMxw5+yxJ7f9O+zXTOqZga6/zFl0IYkiM/u3Q?= =?Windows-1252?Q?goiJ0htUNzsYZT1M2yTvQF7s18SDl6WFVGbByfKv/2DnpkhwPYWQSTAw?= =?Windows-1252?Q?fUYA6GlblILrOFq0aGzKJyb0RPuazAh6fMRosGdXKW+YWftuMXaWxjqA?= =?Windows-1252?Q?Ok6toQCeImc6ybtDO/5T4dZI+GlxnoaLs9LOKB1SpUoX/Y1DQ0P5nQpy?= =?Windows-1252?Q?d4irSoB7i9rVrzEQJGmmehr0qLoncsUGTLd65yR3OewR6Pj2Lp+dxRT1?= =?Windows-1252?Q?7PN7ozaeNv2LufGIj11s4iNU52O6u8LW6YScsPZcza7ZcJIXDlEquwD1?= =?Windows-1252?Q?CZX85S6Y5T26UMqqZMECohAp0MO3ZniQIwLYWz9ReDbri9is55F36bFA?= =?Windows-1252?Q?OAgYgcNqlUkes3Qk92Luvb9wd2NhPEkHnwKaNz7k8VVS2Hh8FRw5tmKl?= =?Windows-1252?Q?QER2+nSRoFI6TFHvgjJ0PiNLC9KLZXbHt6/o+VYIxcjpHwD3Jz77c2jF?= =?Windows-1252?Q?4N0E1Gle6Jo1MkK68RiAZ4j8v8m/bDxFnHoJxl76fYtwadteoba1y00j?= =?Windows-1252?Q?IaS1M1IKksaUQVaaERzeaLf2nKjIWoCe60YPrAmzXCM8V+R/qimOi2V8?= =?Windows-1252? X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-fb43a.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PAXP192MB1608.EURP192.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 0e835260-b15b-4222-9c48-08dbe956af37 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Nov 2023 23:24:31.9157 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0P192MB1866 Received-SPF: pass client-ip=40.92.90.35; envelope-from=vincent.b.1@hotmail.fr; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 19 Nov 2023 22:20:21 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:313035 Archived-At: --_000_PAXP192MB1608F05F8AF80275F28338B884B5APAXP192MB1608EURP_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Just to make my point more clear, with Calc you need to write '(float 12 -1= ) for 1.2, and use calcFunc-add instead of +, ie (apply 'calcFunc-add (ses-= range N3 N6)). Also the cell printer should be math-format-value. Note that with IEEE754 numbers ses+ is not so useful if you are using ses-r= ange as you can delete blank by adding a ! argument, ie (apply 'ses+ (ses-r= ange N3 N6)) is almost the same as (apply '+ (ses-range N3 N6 !)), the sole= difference is that the former does the summing in revert order. V. ________________________________ De : Vincent Bela=EFche Envoy=E9 : lundi 20 novembre 2023 00:18 =C0 : andr=E9s ram=EDrez Cc : emacs-devel ; boruch_baum@gmx.com Objet : RE: using ses programatically (was: a ses question) Hello, Maybe it is due to the order of summing, ses+ is defined as follows: (defun ses+ (&rest args) "Compute the sum of the arguments, ignoring blanks." (apply #'+ (apply #'ses-delete-blanks args))) But ses-delete-blanks will revert the order, so in the second case you sum = N6 N5 N4 N3 and not N3 N4 N5 N6. Have you tried to use in both case '+ or 'ses+, but not '+ in one case and = 'ses+ in the other case. BR, V. PS : Basically you are summing IEEE 754 floating point numbers, so there ar= e some minor rounding errors when converting form decimal to binary and vic= e versa, because IEEE 754 is using a 2 exponent. If you are doing some accounting maybe it is better to use Calc fixed point= numbers, so you would have interger summing and no rounding errors as Calc= is using a 10 exponent. Of course using Calc is less practical, this is one of my big todo to make = SES/Calc interaction easier. ________________________________ De : andr=E9s ram=EDrez Envoy=E9 : dimanche 19 novembre 2023 20:24 =C0 : Vincent Bela=EFche Cc : emacs-devel ; boruch_baum@gmx.com Objet : Re: using ses programatically (was: a ses question) Hi. Vincent. >>>>> "Vincent" =3D=3D Vincent Bela=EFche writes: Vincent> I attached an updated ses-setq macro. [...] I have just tested the last version of ses.el And I have found a trivial difference. When I code: --8<---------------cut here---------------start------------->8--- (ses-setq :: sf N7 (+ N3 N4 N5 N6)) (setq mysum (number-to-string (ses-cell-value 6 13))) (message (format "the sum: '%s'" mysum)) --8<---------------cut here---------------end--------------->8--- the output is: ,---- [ single digit output ] | the sum: =92192.6=92 `---- But then when code is: --8<---------------cut here---------------start------------->8--- (ses-setq :: sf N7 (apply 'ses+ (ses-range N3 N6))) (setq mysum (number-to-string (ses-cell-value 6 13))) (message (format "the sum: '%s'" mysum)) --8<---------------cut here---------------end--------------->8--- the output is: ,---- [ more than one digit decimal output ] | the sum: =92192.60000000000002=92 `---- Any idea why the difference? BTW: yesterday I have found a different issue when using keyboard macros for copying some specific cells to different lines on another buffer. But. Let's end this part for asking about that one. --_000_PAXP192MB1608F05F8AF80275F28338B884B5APAXP192MB1608EURP_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable
Just to make my point more clear, with Calc you need to write '(float 12 -1= ) for 1.2, and use calcFunc-add instead of +, ie (apply 'calcFunc-add (ses-= range N3 N6)). Also the cell printer should be math-format-value.

Note that with IEEE754 numbers ses+ is not so useful if you are using ses-r= ange as you can delete blank by adding a ! argument, ie (apply 'ses+ (ses-r= ange N3 N6)) is almost the same as (apply '+ (ses-range N3 N6 !)), the sole= difference is that the former does the summing in revert order.

  V.

De : Vincent Bela=EFche <= ;vincent.b.1@hotmail.fr>
Envoy=E9 : lundi 20 novembre 2023 00:18
=C0 : andr=E9s ram=EDrez <rrandresf@hotmail.com>
Cc : emacs-devel <emacs-devel@gnu.org>; boruch_baum@gmx.c= om <boruch_baum@gmx.com>
Objet : RE: using ses programatically (was: a ses question)
 
Hello,

Maybe it is due to the order of summing, ses+ is defined as follows:

(defun ses+ (&rest= args)
  "Compute the sum of the arguments, ig= noring blanks."
  (apply #'+ (apply #'ses-delete-blanks args= )))

But ses-delete-blanks will revert the order, so i= n the second case you sum N6 N5 N4 N3 and not N3 N4 N5 N6.

Have you tried to use in both case '+ or 'ses+, b= ut not '+ in one case and 'ses+ in the other case.

BR,
  V.

PS : Basically you are summing IEEE 754<= span style=3D"font-family:"Courier New",monospace; font-size:12pt= ; color:rgb(0,0,0)"> floating point numbers, so there are some minor rounding errors when converting form decimal to binar= y and vice versa, because IEEE 754<= span style=3D"letter-spacing:normal; font-family:"Courier New",mo= nospace; font-size:12pt; font-weight:400; color:rgb(0,0,0); background-colo= r:rgb(255,255,255)"> is using a 2 exponent.
If you are doing some accounting maybe it is bett= er to use Calc fixed point numbers, so you would have interger summing and = no rounding errors as Calc is using a 10 exponent.
Of course using Calc is less practical, this is o= ne of my big todo to make SES/Calc interaction easier.


De : andr=E9s ram=EDrez &= lt;rrandresf@hotmail.com>
Envoy=E9 : dimanche 19 novembre 2023 20:24
=C0 : Vincent Bela=EFche <vincent.b.1@hotmail.fr>
Cc : emacs-devel <emacs-devel@gnu.org>; boruch_baum@gmx.c= om <boruch_baum@gmx.com>
Objet : Re: using ses programatically (was: a ses question)
 
Hi. Vincent.

>>>>> "Vincent" =3D=3D Vincent Bela=EFche <vinc= ent.b.1@hotmail.fr> writes:


    Vincent> I attached an updated ses-setq macro.


[...]

I have just tested the last version of ses.el

And I have found a trivial difference.

When I code:
--8<---------------cut here---------------start------------->8---
      (ses-setq :: sf N7 (+ N3 N4 N5 N6))
      (setq mysum  (number-to-string (ses-cel= l-value 6 13)))
      (message (format "the sum: '%s'"&n= bsp; mysum))
--8<---------------cut here---------------end--------------->8---
the output is:
,---- [ single digit output ]
| the sum: =92192.6=92
`----

But then when code is:
--8<---------------cut here---------------start------------->8---
      (ses-setq :: sf N7 (apply 'ses+ (ses-range N= 3 N6)))
      (setq mysum  (number-to-string (ses-cel= l-value 6 13)))
      (message (format "the sum: '%s'"&n= bsp; mysum))
--8<---------------cut here---------------end--------------->8---
the output is:
,---- [ more than one digit decimal output ]
| the sum: =92192.60000000000002=92
`----

Any idea why the difference?

BTW: yesterday I have found a different issue when using keyboard
macros for copying some specific cells to different lines on another
buffer. But. Let's end this part for asking about that one.
--_000_PAXP192MB1608F05F8AF80275F28338B884B5APAXP192MB1608EURP_--