File: hexstr.m

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (15 lines) | stat: -rw-r--r-- 429 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function str=hexstr(n)
% str=hexstr(n)
% Convert any number to a hex string representing the lower 32 bits,
% emulating the C format %lx for a long. This works with both positive and
% negative numbers, unlike the MATLAB format %x (and %tx and %bx) which
% can't deal with negative numbers.
% 
% fprintf('Error 0x%s.\n',hexstr(err));
% 
% See also DEC2HEX, FPRINTF.

% 4/24/05 dgp Wrote it.

h=dec2hex(n+2^33);
str=h(end-7:end);