octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #64692] colon range includes an extra value


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #64692] colon range includes an extra value
Date: Mon, 25 Sep 2023 13:45:34 -0400 (EDT)

Follow-up Comment #35, bug #64692 (project octave):

sorry missed the second part of jwe's request.  assuming all(rng==fix(rng))
will catch the 'are all integers?' question:


>> rng = 1 : (1001/250)/(1/250);
>> numel(rng), rng(end), all(rng==fix(rng))
ans =
        1000
ans =
        1000
ans =
  logical
   1

>> rng = 2000: -1 : (1001/250)/(1/250);
>> numel(rng), rng(end), all(rng==fix(rng))
ans =
        1000
ans =
   1.0010e+03
ans =
  logical
   0

>> rng = 1 : (1001/250)/(1/250);
>> numel(rng), rng(end), all(rng==fix(rng))
ans =
        1000
ans =
        1000
ans =
  logical
   1


 looking at the second one:


>> rng = 2000: -1 : (1001/250)/(1/250);
>> rng(find(rng~=fix(rng)))
ans =
   1.0e+03 *
  Columns 1 through 6
    1.0240    1.0230    1.0220    1.0210    1.0200    1.0190
  Columns 7 through 12
    1.0180    1.0170    1.0160    1.0150    1.0140    1.0130
  Columns 13 through 18
    1.0120    1.0110    1.0100    1.0090    1.0080    1.0070
  Columns 19 through 24
    1.0060    1.0050    1.0040    1.0030    1.0020    1.0010

>> fix(rng(find(rng~=fix(rng))))
ans =
  Columns 1 through 5
        1023        1022        1021        1020        1019
  Columns 6 through 10
        1018        1017        1016        1015        1014
  Columns 11 through 15
        1013        1012        1011        1010        1009
  Columns 16 through 20
        1008        1007        1006        1005        1004
  Columns 21 through 24
        1003        1002        1001        1000

>> rng(find(rng~=fix(rng)))-[1024:-1:1001]
ans =
   1.0e-12 *
  Columns 1 through 6
   -0.1137   -0.1137   -0.1137   -0.1137   -0.1137   -0.1137
  Columns 7 through 12
   -0.1137   -0.1137   -0.1137   -0.1137   -0.1137   -0.1137
  Columns 13 through 18
   -0.1137   -0.1137   -0.1137   -0.1137   -0.1137   -0.1137
  Columns 19 through 24
   -0.1137   -0.1137   -0.1137   -0.1137   -0.1137   -0.1137

>> ans(1)/eps
ans = 
  -512




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?64692>

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




reply via email to

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