integer artithmetic

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

integer artithmetic

John W. Eaton-6
What should we do for things like

  int16(0) / int16(0)

or

  Inf * int16(0)

?

If both arguments are double, these operations genrate NaNs.  What
should Octave do, given the constraint that the result should be an
int16 object (at least I believe that's the rule that we have to
follow for compatibility)?

Should the result be int16(0)?

Can someone who has Matlab R14 say what it does?

Thanks,

jwe


Reply | Threaded
Open this post in threaded view
|

RE: integer artithmetic

HALL, BENJAMIN            PW
Here's R14 results:

>> a = int16(0)/int16(0)
Warning: Divide by zero.

a =

      0

>> b = Inf*int16(0)

b =

      0

>> whos
  Name      Size                    Bytes  Class

  a         1x1                         2  int16 array
  ans       1x1                         2  int16 array
  b         1x1                         2  int16 array

Grand total is 3 elements using 6 bytes

-----Original Message-----
From: John W. Eaton [mailto:[hidden email]]
Sent: Wednesday, September 01, 2004 2:32 PM
To: octave maintainers mailing list
Subject: integer artithmetic


What should we do for things like

  int16(0) / int16(0)

or

  Inf * int16(0)

?

If both arguments are double, these operations genrate NaNs.  What
should Octave do, given the constraint that the result should be an
int16 object (at least I believe that's the rule that we have to
follow for compatibility)?

Should the result be int16(0)?

Can someone who has Matlab R14 say what it does?

Thanks,

jwe


Reply | Threaded
Open this post in threaded view
|

RE: integer artithmetic

John W. Eaton-6
On  1-Sep-2004, Hall, Benjamin <[hidden email]> wrote:

| Here's R14 results:
|
| >> a = int16(0)/int16(0)
| Warning: Divide by zero.
|
| a =
|
|       0
|
| >> b = Inf*int16(0)
|
| b =
|
|       0

OK, this is what I've done for Octave as well.

Thanks,

jwe