[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[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
does the trick. That is, with that change all 491 tests of your latest version
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
tests, just with your project(s))?
If yes I'll check texinfo, style etc. and then I'll push it.
(file #49738, file #49739)
_______________________________________________________
Additional Item Attachment:
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>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/patch/?9953>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-patch-tracker] [patch #9953] [octave forge] (mapping) angl2str, Philip Nienhuis, 2020/09/02
- [Octave-patch-tracker] [patch #9953] [octave forge] (mapping) angl2str, Ricardo Fantin da Costa, 2020/09/02
- [Octave-patch-tracker] [patch #9953] [octave forge] (mapping) angl2str, Philip Nienhuis, 2020/09/02
- [Octave-patch-tracker] [patch #9953] [octave forge] (mapping) angl2str, Philip Nienhuis, 2020/09/03
- [Octave-patch-tracker] [patch #9953] [octave forge] (mapping) angl2str,
Philip Nienhuis <=
- [Octave-patch-tracker] [patch #9953] [octave forge] (mapping) angl2str, Philip Nienhuis, 2020/09/03
- [Octave-patch-tracker] [patch #9953] [octave forge] (mapping) angl2str, Ricardo Fantin da Costa, 2020/09/03
- [Octave-patch-tracker] [patch #9953] [octave forge] (mapping) angl2str, Philip Nienhuis, 2020/09/04
- [Octave-patch-tracker] [patch #9953] [octave forge] (mapping) angl2str, Ricardo Fantin da Costa, 2020/09/06
- [Octave-patch-tracker] [patch #9953] [octave forge] (mapping) angl2str, Philip Nienhuis, 2020/09/07
- [Octave-patch-tracker] [patch #9953] [octave forge] (mapping) angl2str, Philip Nienhuis, 2020/09/07