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

Add a New Comment Rich Markup

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


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

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


CC list is empty


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 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.13-d3ae.
Corresponding source code