[Top][All Lists]

[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;


does the trick. That is, with that change all 491 tests of your latest version

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));
    ret = round (x / 10^abs (n)) * 10 ^ abs (n);

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

File name: angl2str.m                     Size:38 KB


Reply to this item at:


  Message sent via Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]