bugGNU Octave - Bugs: bug #34502, bitXXX functions do not accept...

 
 

bug #34502: bitXXX functions do not accept arguments of class 'single'

Submitter:  Rik <rik5>
Submitted:  Fri 07 Oct 2011 04:48:34 PM UTC
   
 
Category:  Libraries Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Feature Request
Status:  Fixed Assigned to:  mtmiller
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 08 Sep 2013 10:14:40 PM UTC, comment #6: 

Ok, I've worked out the remaining issues that I ran into while adding support for this. I replaced the hardcoded floating point bit widths with calls to numeric_limits, reimplemented flintmax to be Matlab-compatible, and tested everything for consistency and it all seems to work as far as I can tell. Pushed these changes:

http://hg.savannah.gnu.org/hgweb/octave/rev/dbdff94bf977
http://hg.savannah.gnu.org/hgweb/octave/rev/4bcd301754ce
http://hg.savannah.gnu.org/hgweb/octave/rev/7d8d194f3f63
http://hg.savannah.gnu.org/hgweb/octave/rev/e09cd91168d1

I couldn't really come up with a good way to describe how flintmax differs from bitmax, feel free to rewrite either or both of their docstrings to make it clearer.

Mike Miller <mtmiller>
Group Member
Fri 06 Sep 2013 04:36:00 PM UTC, comment #5: 

Your patch seems OK, but I didn't test it.

Do we need to be careful about hard-wiring things like 32 bits in a single and 24 bits in the mantissa?  I guess it is OK, we are pretty deep in with the assumption of IEEE floating point math these days, so maybe we will never have to worry about that changing.

John W. Eaton <jwe>
Group administrator
Fri 06 Sep 2013 04:17:00 PM UTC, comment #4: 

Yeah I saw the flintmax alias but unfortunately the MATLAB docs say that the return value is different from the now-deprecated bitmax. I'll take care of all of these issues if neither of you beat me to it.

Back to this bug, any comments on my patch?

Mike Miller <mtmiller>
Group Member
Fri 06 Sep 2013 02:57:39 PM UTC, comment #3: 

I had noticed the flintmax replacement by Matlab and added a DEFALIAS so Octave will accept either flintmax or bitmax.  I kind of liked the name bitmax so I left it in.

Rik <rik5>
Group administrator
Fri 06 Sep 2013 02:18:00 PM UTC, comment #2: 

I'd say yes, bitmax ("single") should return a single value.

According to the Matlab docs, bitmap does not appear to accept an argument for single.  Also, it seems that bitmax is being replaced by flintmax which does accept an argument, either "single" or "double" (the default).

John W. Eaton <jwe>
Group administrator
Fri 06 Sep 2013 05:10:56 AM UTC, comment #1: 

This seems useful to me so I went ahead and got all the bit functions working. I think I got all of the type promotion working correctly, please take a look at the attached changeset and let me know if I missed anything or if there is a simpler way to structure it.

Related to this, should bitmax ("single") return a variable of type single? It currently returns double, so for now there is a typecast in one of the new unit tests to get around that.

(file #29022)

Mike Miller <mtmiller>
Group Member
Fri 07 Oct 2011 04:48:34 PM UTC, original submission:  

Sample code


x = single (0);
bitset (x, 4)
error: bitshift: not defined for single objects
error: called from:
error:   /home/rik/wip/Projects_Mine/octave-dev/scripts/general/bitset.m at line 91, column 8


Updating the bitXXX.m scripts in the general directory looks pretty straightforward.  However, there does need to be some support in src/bitfcns.cc for single arguments as well (bitshift, maybe others).

Rik <rik5>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #29022:  single-bitops.patch added by mtmiller (7KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by rik5 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-09-08 mtmiller StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2013-09-06 mtmiller StatusConfirmed Patch Submitted
        Assigned toNone mtmiller
    2013-09-06 mtmiller Attached File- Added single-bitops.patch, #29022
    2012-02-27 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code