[Top][All Lists]

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

[Octave-bug-tracker] [bug #51556] function isreal applied on complex num

From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #51556] function isreal applied on complex numbers with zero imaginary part
Date: Mon, 24 Jul 2017 09:26:20 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0

Follow-up Comment #2, bug #51556 (project octave):

In Matlab, (and Octave, for compatibility reasons) if you want to create a
complex value with a zero imaginary part, you need to use something like
"complex (r, 0)".  And even then, if you use that value in an expression like

x = complex (12, 0)  %% 12+0i
isreal (x)           %% false
y = 1 + x            %% 13
isreal (y)           %% true

you will get a real value as the final result because of the automatic complex
-> real conversion rules for (nearly all) expression results.

I'm certainly not claiming this is mathematically correct or necessarily the
best programming language design.  But it is the way Matlab works and we have
to do the same for compatibility reasons.  If we didn't, we'd be constantly
getting bug reports that Octave fails on code that works perfectly well in


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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