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

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

[Octave-bug-tracker] [bug #45945] Missing Matlab's special support for i


From: Amro
Subject: [Octave-bug-tracker] [bug #45945] Missing Matlab's special support for int64/uint64 integer literals
Date: Tue, 23 Aug 2016 10:34:34 +0000 (UTC)
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0

Follow-up Comment #22, bug #45945 (project octave):

@mtmiller comment #15:

_(Everything below is tested in MATLAB R2016a on Windows x64)_

The case of overloading with a class method:


>> x = foo;
>> y = x.int64(9223372036854775806)
foo
double
y =
     9.223372036854776e+18
>> z = 9223372036854775806;
>> isequal(y,z)
ans =
     1


The case of overloading with a package function:


>> z = 9223372036854775806;
>> y = mypkg.int64(9223372036854775806)
double
y =
     9.223372036854776e+18
>> isequal(y,z)
ans =
     1
>> 
>> import mypkg.int64
>> y = int64(9223372036854775806)
double
double
y =
     9.223372036854776e+18
>> isequal(y,z)
ans =
     1


The case of overloading with a function handle:


>> int64 = @abs;
>> int64(9223372036854775806)
ans =
     9.223372036854776e+18
>> class(ans)
ans =
double
>> int64(-2)
ans =
     2
>> class(ans)
ans =
double


The case of indirectly calling int64 using a function handle:


>> int64(9223372036854775806)
ans =
  9223372036854775806
>> fcn = @int64;
>> fcn(9223372036854775806)
ans =
  9223372036854775807
>> class(ans)
ans =
int64
>> fcn(-2)
ans =
                   -2
>> class(ans)
ans =
int64


All the above confirm the fact that MATLAB treats "u?int64(_literal-number_)"
as a special case only when called directly, non-overloaded, and with
integer-like literal argument.
Your third example shows that it is likely not naively handled during parsing,
but later on after resolving symbols and overloaded functions.


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?45945>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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