help-octave
[Top][All Lists]
Advanced

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

Re: Basic question: usage of Java methods in Octave


From: Michael Goffioul
Subject: Re: Basic question: usage of Java methods in Octave
Date: Wed, 16 Oct 2013 09:40:39 -0400

On Wed, Oct 16, 2013 at 8:51 AM, PhilipNienhuis <address@hidden> wrote:
>> Actually, because it's a static method, it should be something like:
>>
>> x.floatToIntBits(x)

x.toString

(toString is a static method as well) works all right, so Octave is at least
a bit inconsistent.

No, it's not static. There's actually 2 "toString" methods, one static, one regular. By the signature of "x.toString()", you're automatically choosing the regular method. This is different than "floatToIntBits", which is only static. AFAIK, you can't do "x.floatToIntBits()" in java either.

 
As to Matlab:
r2012a does this:

============================================
>> x = javaObject ('java.lang.Float', 10.07)

x =

10.07

>> x.floatToIntBits
No method 'floatToIntBits' with matching signature found for class
'java.lang.Float'.

>> x.floatToIntBits()
No method 'floatToIntBits' with matching signature found for class
'java.lang.Float'.

>> methods (x)

Methods for class java.lang.Float:

Float              floatToRawIntBits  isNaN              toString
byteValue          floatValue         longValue          valueOf
compare            getClass           notify             wait
compareTo          hashCode           notifyAll
doubleValue        intBitsToFloat     parseFloat
equals             intValue           shortValue
floatToIntBits     isInfinite         toHexString

>> javaMethod ('floatToIntBits', x)
Error using javaMethod
No floatToIntBits method with appropriate signature
exists in Java class java.lang.Float

As I said above, this is expected. There is no floatToIntBits method with that signature (0 arguments).

Michael.


reply via email to

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