octave-patch-tracker
[Top][All Lists]

## [Octave-patch-tracker] [patch #9953] [octave forge] (mapping) angl2str

 From: Philip Nienhuis Subject: [Octave-patch-tracker] [patch #9953] [octave forge] (mapping) angl2str Date: Thu, 3 Sep 2020 16:44:20 -0400 (EDT) User-agent: Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0

```Follow-up Comment #17, patch #9953 (project octave):

Looking at roundn.m and playing around a little, I see that replacing
subfunction round_a as follows

function [num] = round_a (X, N = 0)

##  if (N == 0)
##    num = floor (X + 0.5);
##  else
##    multiplier = 10 .** (N);
##    num = (floor ((X .* multiplier) + 0.5)) ./ multiplier;
##  endif

num = round (X / 10^-N) * 10^-N;

endfunction

pass.

Now, looking at roundn.m and comparing with Matlab, I conclude that replacing
its working part

:
if (mod (x, 1) != 0)
ret = round (10^abs (n) * x) / (10^abs (n));
else
ret = round (x / 10^abs (n)) * 10 ^ abs (n);
endif
:

by just

:
ret = round (x / 10^n) * 10^n;
:

makes it fully Matlab-compatible, AFAICS.

So in angl2str.m I replaced all calls to round_a with calls to roundn, deleted
subfunction round_a, and changed sign of the second argument, and again all
491 tests pass.

I upload that patched angl2str.m and the patched roundn.m; can you confirm my
analysis and check that anglstr.m works for you as well (outside from the BIST

If yes I'll check texinfo, style etc. and then I'll push it.

(file #49738, file #49739)
_______________________________________________________

File name: roundn.m                       Size:1 KB
<https://file.savannah.gnu.org/file/roundn.m?file_id=49738>

File name: angl2str.m                     Size:38 KB
<https://file.savannah.gnu.org/file/angl2str.m?file_id=49739>

_______________________________________________________

<https://savannah.gnu.org/patch/?9953>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

```