octave-maintainers
[Top][All Lists]
Advanced

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

Re: [CHANGESET]: First attempt at a single precision type.


From: John W. Eaton
Subject: Re: [CHANGESET]: First attempt at a single precision type.
Date: Mon, 28 Apr 2008 13:03:39 -0400

On 28-Apr-2008, David Bateman wrote:

| I thought about this further and it seems that matlab's behavior for
| mixed operators is
| 
| double OP int -> int
| single OP int   -> error
| double OP single -> single

The behavior is documented in the

  Programming Fundamentals
    Built-In Classes (Data Types)
      Numeric Classes
        Floating-Point Numbers
          Arithmetic Operations on Floating-Point Numbers

section of the online documentation for Matlab.

To summarize:

Mixed operations for double are valid for the following types.  The
result is double except where noted.

  single (result is single)
  double
  intX or uintX (result is intX or uintX; double value must be a scalar)
  char
  logical

Mixed operations for single are valid for the following types.  The
result is always single.

  single
  double
  char
  logical

I'm guessing that the fact that a simple numeric constant like 13 is
double in Matlab has something to do with the conversion rules, and
also the "double value must be scalar" restriction for mixed
double/integer operations.  It would be painful to have to always
write

  my_int8_var = my_int8_var + int8 (1);

jwe


reply via email to

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