[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: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #45945] Missing Matlab's special support for integer literals |
Date: |
Sat, 12 Sep 2015 19:03:03 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0 Iceweasel/38.2.1 |
URL:
<http://savannah.gnu.org/bugs/?45945>
Summary: Missing Matlab's special support for integer
literals
Project: GNU Octave
Submitted by: None
Submitted on: Sat 12 Sep 2015 07:03:02 PM UTC
Category: Interpreter
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: WTF, Matlab?!?
Status: None
Assigned to: None
Originator Name: Chris Wellons
Originator Email: address@hidden
Open/Closed: Open
Discussion Lock: Any
Release: 3.8.2
Operating System: GNU/Linux
_______________________________________________________
Details:
In Octave:
octave:1> uint64(18446744073709551614)
ans = 18446744073709551615
But in Matlab I get:
ans = 18446744073709551614
This behavior is not documented by MathWorks, but from experimentation it
looks like the Matlab interpreter treats conversion functions as special when
the argument is an integer-like literal. It doesn't use an intermediate
double-precision value as you would expect. For example, make it any
expression at all and Octave and Matlab will agree on the output, due to the
intermediate double result:
octave:4> uint64(18446744073709551614 * 1)
ans = 18446744073709551615
It's weird, but it's at least a way to specify an integer literal, otherwise
absent from the language.
Very similarly, Octave and Matlab disagree on str2num here:
str2num('uint64(18446744073709551614)')
Ran into all this when I was trying to put large integer values in my code.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?45945>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #45945] Missing Matlab's special support for integer literals,
anonymous <=