bugGNU Octave - Bugs: bug #47744, printf family of functions does...

 
 

bug #47744: printf family of functions does not support %b[ouxX] or %t[ouxX] conversions

Submitter:  Mike Miller <mtmiller>
Submitted:  Wed 20 Apr 2016 09:26:03 PM UTC
   
 
Category:  Octave Function Severity:  1 - Wish
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Postponed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Post a Comment

Add a New Comment Rich Markup
   

Discussion

Wed 20 Apr 2016 09:51:23 PM UTC, comment #2: 

And the "%tx" format is especially annoying because it conflicts with POSIX, which treats "t" to mean an integer argument of type ptrdiff_t.

Mike Miller <mtmiller>
Group Member
Wed 20 Apr 2016 09:31:40 PM UTC, comment #1: 

I see this was briefly discussed in bug #44245 but dismissed, I think it's better to track this separately and leave it for someone to implement if they wish.

I agree these are confusing because they look like integer conversions, but they actually operate on floating point arguments. But this appears to be the only way in Matlab to print the byte values of a floating point value.

Mike Miller <mtmiller>
Group Member
Wed 20 Apr 2016 09:26:03 PM UTC, original submission:  

For Matlab compatibility, the printf family of functions should support the following conversion specifiers:


%bo, %bu, %bx, %bX - double-precision value representation in octal, decimal, or hexadecimal
%to, %tu, %tx, %tX - single-precision value representation in octal, decimal, or hexadecimal


I'm not completely sure, but I guess they mean it should interpret the variable's storage location as if it were an integer and display the integer value in the appropriate base.

They give these two examples:


sprintf('%bx', pi) → 400921fb54442d18
sprintf('%tx', pi) → 40490fdb


These are the same values that Octave gives for something like


dec2hex (typecast (double_value, "uint64"))
dec2hex (typecast (single_value, "uint32"))


Mike Miller <mtmiller>
Group Member

 

Attached Files

This item currently has no attached files.

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

Attach Files:
   
   
Comment:
   

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

 

Votes

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.

 

History

Follow 3 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2019-02-26 mtmiller Carbon-CopyRemoved 80942 -
2016-04-20 mtmiller Severity3 - Normal 1 - Wish
    StatusNone Postponed

Back to the top

Powered by Savane 3.16-ed84.
Corresponding source code