[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #41461] cast to integer type incorrect
From: |
Mike Sander |
Subject: |
[Octave-bug-tracker] [bug #41461] cast to integer type incorrect |
Date: |
Wed, 05 Feb 2014 02:44:27 +0000 |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0 |
URL:
<http://savannah.gnu.org/bugs/?41461>
Summary: cast to integer type incorrect
Project: GNU Octave
Submitted by: msander
Submitted on: Wed 05 Feb 2014 02:44:26 AM GMT
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: mike sander
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: Any
_______________________________________________________
Details:
octave:1> x=int8(-128)
x = -128
octave:2> z=char(x)
warning: range error for conversion to character value
error: value on right hand side of assignment is undefined
I believe this should return 0. This assumes char maps to unsigned 8 bit
type.
octave:2> x=256
x = 256
octave:3> z=char(x)
warning: range error for conversion to character value
z =
octave:4> single(z) # to show value
ans = 0
this should return 255.
The attached patch (cast_integer01.diff) has a proposed fix for integer types.
I am open to comments/suggestions. Specifically is use of
std::numeric_limits appropriate in this context?
NB. bug #38956 is related, but only considers +ve portion, not the undefined
value.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Wed 05 Feb 2014 02:44:26 AM GMT Name: cast_integer01.diff Size: 1kB
By: msander
<http://savannah.gnu.org/bugs/download.php?file_id=30460>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?41461>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #41461] cast to integer type incorrect,
Mike Sander <=
- [Octave-bug-tracker] [bug #41461] cast to integer type incorrect, Michael Godfrey, 2014/02/04
- [Octave-bug-tracker] [bug #41461] cast to integer type incorrect, Mike Sander, 2014/02/05
- [Octave-bug-tracker] [bug #41461] cast to integer type incorrect, Michael Godfrey, 2014/02/05
- [Octave-bug-tracker] [bug #41461] cast to integer type incorrect, John W. Eaton, 2014/02/05
- Message not available
- [Octave-bug-tracker] [bug #41461] cast to integer type incorrect, anonymous, 2014/02/05
- [Octave-bug-tracker] [bug #41461] cast to integer type incorrect, Mike Sander, 2014/02/07
- [Octave-bug-tracker] [bug #41461] cast to integer type incorrect, Mike Sander, 2014/02/07