<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Potřeboval jsem proměnné vypsat v hexadecimálním tvaru. K mému
údivu</p>
<div style="color: #4e5b61;background-color: #ffffff;font-family: Consolas, 'Courier New', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;"><div><span style="color: #4e5b61;"> </span><span style="color: #d35400;">Serial</span><span style="color: #4e5b61;">.</span><span style="color: #d35400;">println</span><span style="color: #434f54;">(</span><span style="color: #005c5f;">0</span><span style="color: #4e5b61;">,HEX</span><span style="color: #434f54;">)</span><span style="color: #4e5b61;">;</span></div><div><span style="color: #4e5b61;"> </span><span style="color: #d35400;">Serial</span><span style="color: #4e5b61;">.</span><span style="color: #d35400;">println</span><span style="color: #434f54;">(</span><span style="color: #005c5f;">254</span><span style="color: #4e5b61;">,HEX</span><span style="color: #434f54;">)</span><span style="color: #4e5b61;">;</span></div><div><span style="color: #4e5b61;"> </span><span style="color: #d35400;">Serial</span><span style="color: #4e5b61;">.</span><span style="color: #d35400;">println</span><span style="color: #434f54;">(</span><span style="color: #005c5f;">255</span><span style="color: #4e5b61;">,HEX</span><span style="color: #434f54;">)</span><span style="color: #4e5b61;">;</span></div><div><span style="color: #4e5b61;"> </span><span style="color: #00979d;">char</span><span style="color: #4e5b61;"> d=0x</span><span style="color: #005c5f;">FF</span><span style="color: #4e5b61;">;</span></div><div><span style="color: #4e5b61;"> </span><span style="color: #d35400;">Serial</span><span style="color: #4e5b61;">.</span><span style="color: #d35400;">println</span><span style="color: #434f54;">(</span><span style="color: #4e5b61;">d,HEX</span><span style="color: #434f54;">)</span><span style="color: #4e5b61;">;</span></div>
dá hodnoty:</div>
<div style="color: #4e5b61;background-color: #ffffff;font-family: Consolas, 'Courier New', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;">
</div>
<p></p>
<pre class="moz-signature" cols="72">0
FE
FF
FFFFFFFF
dělá Vám to taky nebo už blbnu? Očekával jsem dva hexadecimální znaky ve všech případech. Obelstil jsem to touto funkcí:
</pre>
<div style="color: #4e5b61;background-color: #ffffff;font-family: Consolas, 'Courier New', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;"><div><span style="color: #00979d;">void</span><span style="color: #4e5b61;"> </span><span style="color: #d35400;">hexprint</span><span style="color: #434f54;">(</span><span style="color: #00979d;">char</span><span style="color: #4e5b61;"> </span><span style="color: #434f54;">c)</span><span style="color: #4e5b61;"> </span><span style="color: #434f54;">{</span></div><div><span style="color: #4e5b61;"> </span><span style="color: #728e00;">if</span><span style="color: #4e5b61;"> </span><span style="color: #434f54;">(</span><span style="color: #d35400;">byte</span><span style="color: #434f54;">(</span><span style="color: #4e5b61;">c</span><span style="color: #434f54;">)</span><span style="color: #4e5b61;"><</span><span style="color: #005c5f;">16</span><span style="color: #434f54;">)</span><span style="color: #4e5b61;"> </span><span style="color: #d35400;">Serial</span><span style="color: #4e5b61;">.</span><span style="color: #d35400;">print</span><span style="color: #4e5b61;"> </span><span style="color: #434f54;">(</span><span style="color: #005c5f;">"0"</span><span style="color: #434f54;">)</span><span style="color: #4e5b61;">;</span></div><div><span style="color: #4e5b61;"> </span><span style="color: #d35400;">Serial</span><span style="color: #4e5b61;">.</span><span style="color: #d35400;">print</span><span style="color: #434f54;">(</span><span style="color: #d35400;">byte</span><span style="color: #434f54;">(</span><span style="color: #4e5b61;">c</span><span style="color: #434f54;">)</span><span style="color: #4e5b61;">,HEX</span><span style="color: #434f54;">)</span><span style="color: #4e5b61;">;</span></div><span style="color: #434f54;">}</span><span style="color: #4e5b61;">;</span></div>
<pre class="moz-signature" cols="72">Ale je to rovnák na ohýbák.
--
Martin Záruba
</pre>
</body>
</html>