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 are some minor rounding errors when converting form decimal to binary and vice 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és ramírez <rrandresf@hotmail.com>
Envoyé : dimanche 19 novembre 2023 20:24
À : Vincent Belaïche <vincent.b.1@hotmail.fr>
Cc : emacs-devel <emacs-devel@gnu.org>; boruch_baum@gmx.com <boruch_baum@gmx.com>
Objet : Re: using ses programatically (was: a ses question)
 
Hi. Vincent.

>>>>> "Vincent" == Vincent Belaïche <vincent.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-cell-value 6 13)))
      (message (format "the sum: '%s'"  mysum))
--8<---------------cut here---------------end--------------->8---
the output is:
,---- [ single digit output ]
| the sum: ’192.6’
`----

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: ’192.60000000000002’
`----

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.