Add a New Comment (Rich Markup)
And the "%tx" format is especially annoying because it conflicts with POSIX, which treats "t" to mean an integer argument of type ptrdiff_t.
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.
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"))
(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)
Attach Files: Comment:
No files currently attached
Depends on the following items: None found
Items that depend on this one: None found
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 project members can vote.
Please enter the title of George Orwell's famous dystopian book (it's a date):
Follow 3 latest changes.
Copyright © 2023 Free Software Foundation, Inc. Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. The Levitating, Meditating, Flute-playing Gnu logo is a GNU GPL'ed image provided by the Nevrax Design Team. Source Code
Powered by Savane 3.11