help-octave
[Top][All Lists]
Advanced

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

Re: char to int conversion problem


From: David Bateman
Subject: Re: char to int conversion problem
Date: Sun, 29 Apr 2007 22:01:36 +0200
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

Alessandro Brezzi wrote:
> Hi all,
> I'm a newbe in Octave, so sorry for a dumb question.
> 
> I've tried a small piece of code:
> 
> octave:1> a='A';
> octave:2> b=int8(a);
> error: invalid conversion from sq_string to int8 scalar
> error: evaluating assignment expression near line 2, column 2
> 
> The same code is right in MatLab. What I've missed?
> 
> Thanks in advance
> 
> Octave version: GNU Octave, version 2.9.9 (x86_64-redhat-linux-gnu).
> Linux system:  Linux hrexx.homelinux.net <http://hrexx.homelinux.net>
> 2.6.20-1.2944.fc6 #1 SMP Tue Apr 10 17:46:00 EDT 2007 x86_64 x86_64
> x86_64 GNU/Linux
> -- 
> Alessandro Brezzi
> 
> 

Yes this is a bug. Note octave has string delimited by both '' and "",
and treats them slightly different (escape characters are interpreted in
"" strings)..

Try the attached patch, it works for me :-)... Note that with "" it
worked before in any case..

D.

*** ./src/OPERATORS/op-int-conv.cc.orig24       2005-04-26 21:24:35.000000000 
+0200
--- ./src/OPERATORS/op-int-conv.cc      2007-04-29 21:52:57.054301425 +0200
***************
*** 87,101 ****
  DEFCONVFN (bool_matrix_to_uint32, bool_matrix, uint32)
  DEFCONVFN (bool_matrix_to_uint64, bool_matrix, uint64)
  
! DEFSTRINTCONVFN (char_matrix_str_to_int8, int8)
! DEFSTRINTCONVFN (char_matrix_str_to_int16, int16)
! DEFSTRINTCONVFN (char_matrix_str_to_int32, int32)
! DEFSTRINTCONVFN (char_matrix_str_to_int64, int64)
! 
! DEFSTRINTCONVFN (char_matrix_str_to_uint8, uint8)
! DEFSTRINTCONVFN (char_matrix_str_to_uint16, uint16)
! DEFSTRINTCONVFN (char_matrix_str_to_uint32, uint32)
! DEFSTRINTCONVFN (char_matrix_str_to_uint64, uint64)
  
  DEFCONVFN (range_to_int8, range, int8)
  DEFCONVFN (range_to_int16, range, int16)
--- 87,111 ----
  DEFCONVFN (bool_matrix_to_uint32, bool_matrix, uint32)
  DEFCONVFN (bool_matrix_to_uint64, bool_matrix, uint64)
  
! DEFSTRINTCONVFN (char_matrix_sq_str_to_int8, int8)
! DEFSTRINTCONVFN (char_matrix_sq_str_to_int16, int16)
! DEFSTRINTCONVFN (char_matrix_sq_str_to_int32, int32)
! DEFSTRINTCONVFN (char_matrix_sq_str_to_int64, int64)
! 
! DEFSTRINTCONVFN (char_matrix_sq_str_to_uint8, uint8)
! DEFSTRINTCONVFN (char_matrix_sq_str_to_uint16, uint16)
! DEFSTRINTCONVFN (char_matrix_sq_str_to_uint32, uint32)
! DEFSTRINTCONVFN (char_matrix_sq_str_to_uint64, uint64)
! 
! DEFSTRINTCONVFN (char_matrix_dq_str_to_int8, int8)
! DEFSTRINTCONVFN (char_matrix_dq_str_to_int16, int16)
! DEFSTRINTCONVFN (char_matrix_dq_str_to_int32, int32)
! DEFSTRINTCONVFN (char_matrix_dq_str_to_int64, int64)
! 
! DEFSTRINTCONVFN (char_matrix_dq_str_to_uint8, uint8)
! DEFSTRINTCONVFN (char_matrix_dq_str_to_uint16, uint16)
! DEFSTRINTCONVFN (char_matrix_dq_str_to_uint32, uint32)
! DEFSTRINTCONVFN (char_matrix_dq_str_to_uint64, uint64)
  
  DEFCONVFN (range_to_int8, range, int8)
  DEFCONVFN (range_to_int16, range, int16)
***************
*** 178,184 ****
    INSTALL_CONVOPS (bool)
    INSTALL_CONVOPS (bool_matrix)
    INSTALL_CONVOPS (range)
!   INSTALL_CONVOPS (char_matrix_str)
  
    INSTALL_INT_CONV_FUNCTIONS (int8)
    INSTALL_INT_CONV_FUNCTIONS (int16)
--- 188,195 ----
    INSTALL_CONVOPS (bool)
    INSTALL_CONVOPS (bool_matrix)
    INSTALL_CONVOPS (range)
!   INSTALL_CONVOPS (char_matrix_sq_str)
!   INSTALL_CONVOPS (char_matrix_dq_str)
  
    INSTALL_INT_CONV_FUNCTIONS (int8)
    INSTALL_INT_CONV_FUNCTIONS (int16)

reply via email to

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