octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bad mod function


From: Vic Norton
Subject: bad mod function
Date: Tue, 19 Jun 2018 08:33:43 -0400

The mod function in my Mac system is not working. This is my system
----------------------------------------------------------------------
GNU Octave Version: 4.4.0 (hg id: d703d8bbc6ae)
GNU Octave License: GNU General Public License
Operating System: Darwin 16.7.0
Darwin Kernel Version 16.7.0: Fri Apr 27 17:59:46 PDT 2018;
root:xnu-3789.73.13~1/RELEASE_X86_64 x86_64
----------------------------------------------------------------------
/usr/local/Cellar/octave/4.4.0_1 (2,189 files, 48.5MB) *
  Poured from bottle on 2018-06-16 at 10:40:43
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/octave.rb

The mod problem appears to be a very recent glitch. I’ve used mod quite 
recently with no problem.

Here is a script that shows the problem.

% the way mod is supposed to be defined
function v = modxy(x, y)  % to replace the faulty mod function
  v = x - y .* floor (x ./ y);
end

% example of the problem
fprintf('-- bad mod function ---\n');
for i = 1 : 11
  fprintf('%4d', i);
  if mod(i, 5) == 1; fprintf('\n'); end
end
fprintf('-- good mod function --\n');
for i = 1 : 11
  fprintf('%4d', i);
  if modxy(i, 5) == 1; fprintf('\n'); end
end
%{
output:
-- bad mod function ---
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
-- good mod function --
   1
   2   3   4   5   6
   7   8   9  10  11
%}

Regards,

Vic


reply via email to

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