<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Duda con python pack y unpack</title>
	<atom:link href="http://cofradia.org/2009/02/22/duda-con-python-pack-y-unpack/feed/" rel="self" type="application/rss+xml" />
	<link>http://cofradia.org/2009/02/22/duda-con-python-pack-y-unpack/</link>
	<description>Hermandad informática</description>
	<lastBuildDate>Thu, 17 May 2012 20:40:19 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: gwolf</title>
		<link>http://cofradia.org/2009/02/22/duda-con-python-pack-y-unpack/comment-page-1/#comment-1062</link>
		<dc:creator>gwolf</dc:creator>
		<pubDate>Tue, 24 Feb 2009 13:30:21 +0000</pubDate>
		<guid isPermaLink="false">http://cofradia.org/?p=929#comment-1062</guid>
		<description>Hoy en día, ya no puedes asumir que cualquier representación interna de objetos opacos sea representable como caracteres. No, no estás hablando ya de caracteres ASCII (ese es el plural correcto - ASCII se refiere a _un_ estándar, y no puede por tanto ser pluralizado; &quot;caracter ASCII&quot; es el singular, &quot;caracteres ASCII&quot; el plural) - ASCII va de 0x00 a 0x7F (o del 0 al 128), de los cuales los primeros 32 caracteres no necesariamente tienen representación imprimible. En el caso de tu ejemplo tienes un 0xCC y un 0xCD, que caben en algunas extensiones a ASCII (como ISO-8859-1)... Pero si tu consola es Unicode, tienes cadenas inválidas.
Pack y unpack sirven para manejar representaciones binarias - no los uses con un print. En todo caso, rodéalos de algún serializador, como YAML.</description>
		<content:encoded><![CDATA[<p>Hoy en día, ya no puedes asumir que cualquier representación interna de objetos opacos sea representable como caracteres. No, no estás hablando ya de caracteres ASCII (ese es el plural correcto &#8211; ASCII se refiere a _un_ estándar, y no puede por tanto ser pluralizado; &#8220;caracter ASCII&#8221; es el singular, &#8220;caracteres ASCII&#8221; el plural) &#8211; ASCII va de 0&#215;00 a 0x7F (o del 0 al 128), de los cuales los primeros 32 caracteres no necesariamente tienen representación imprimible. En el caso de tu ejemplo tienes un 0xCC y un 0xCD, que caben en algunas extensiones a ASCII (como ISO-8859-1)&#8230; Pero si tu consola es Unicode, tienes cadenas inválidas.<br />
Pack y unpack sirven para manejar representaciones binarias &#8211; no los uses con un print. En todo caso, rodéalos de algún serializador, como YAML.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: huguin</title>
		<link>http://cofradia.org/2009/02/22/duda-con-python-pack-y-unpack/comment-page-1/#comment-1061</link>
		<dc:creator>huguin</dc:creator>
		<pubDate>Mon, 23 Feb 2009 18:58:19 +0000</pubDate>
		<guid isPermaLink="false">http://cofradia.org/?p=929#comment-1061</guid>
		<description>gracias gunnar!
a lo que me refería es que no entendía la respuesta de python a la instrucció unpack, que da esto
‘?L\xcc\xcd’, 
hasta que me di cuenta que cuando le pides al shell que te muestre el contenido, 
trata de imprimir ASCII&#039;s (¿es correcto este plural?),  cuando puede y si no puede usa ya las secuencias de 
escape \x. Realmente en la memoria si hay un   3f  4c  cc  cd  , solo que el 3f lo imprime porque es ASCII como ? y el 4c como L. Pero yo quería ver que python me dijiese  \x3f\x4c\xcc\xcd, pero bueno eso me saco por newbie.</description>
		<content:encoded><![CDATA[<p>gracias gunnar!<br />
a lo que me refería es que no entendía la respuesta de python a la instrucció unpack, que da esto<br />
‘?L\xcc\xcd’,<br />
hasta que me di cuenta que cuando le pides al shell que te muestre el contenido,<br />
trata de imprimir ASCII&#8217;s (¿es correcto este plural?),  cuando puede y si no puede usa ya las secuencias de<br />
escape \x. Realmente en la memoria si hay un   3f  4c  cc  cd  , solo que el 3f lo imprime porque es ASCII como ? y el 4c como L. Pero yo quería ver que python me dijiese  \x3f\x4c\xcc\xcd, pero bueno eso me saco por newbie.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gwolf</title>
		<link>http://cofradia.org/2009/02/22/duda-con-python-pack-y-unpack/comment-page-1/#comment-1060</link>
		<dc:creator>gwolf</dc:creator>
		<pubDate>Mon, 23 Feb 2009 17:50:26 +0000</pubDate>
		<guid isPermaLink="false">http://cofradia.org/?p=929#comment-1060</guid>
		<description>Lo que ves es completamente normal - y no privativo de Python:
&lt;pre lang=&quot;perl&quot;&gt;$ perl -e &#039;print unpack(&quot;f&quot;, pack(&quot;f&quot;, 0.8))&#039;
0.8000000119209290&lt;/pre&gt;
¿Por qué? Porque estás hablando de punto flotante. La aritmética de punto flotante te da gran flexibilidad en el rango en el cual puedes operar (porque no guarda la cantidad tal cual, sino que la cantidad y su magnitud), pero pierde precisión en los dígitos menos significativos. Vamos, igual que con 0.8, esto podrías haberlo visto con números muy grandes:
&lt;pre lang=&quot;perl&quot;&gt;$ perl -e &#039;for my $exp (-10..20) {print &quot;8 * 10 ^ $exp: &quot;, unpack(&quot;f&quot;, pack(&quot;f&quot;, 8*10**$exp)),&quot;\n&quot;}&#039;
8 * 10 ^ -10: 8.00000010681146e-10
8 * 10 ^ -9: 7.99999977374455e-09
8 * 10 ^ -8: 7.99999995138023e-08
8 * 10 ^ -7: 8.00000009348878e-07
8 * 10 ^ -6: 7.99999997980194e-06
8 * 10 ^ -5: 7.999999797903e-05
8 * 10 ^ -4: 0.0007999999797903
8 * 10 ^ -3: 0.00800000037997961
8 * 10 ^ -2: 0.0799999982118607
8 * 10 ^ -1: 0.800000011920929
8 * 10 ^ 0: 8
8 * 10 ^ 1: 80
8 * 10 ^ 2: 800
8 * 10 ^ 3: 8000
8 * 10 ^ 4: 80000
8 * 10 ^ 5: 800000
8 * 10 ^ 6: 8000000
8 * 10 ^ 7: 80000000
8 * 10 ^ 8: 800000000
8 * 10 ^ 9: 8000000000
8 * 10 ^ 10: 80000000000
8 * 10 ^ 11: 799999983616
8 * 10 ^ 12: 7999999967232
8 * 10 ^ 13: 79999998623744
8 * 10 ^ 14: 800000003014656
8 * 10 ^ 15: 7.99999989592883e+15
8 * 10 ^ 16: 8.00000021805138e+16
8 * 10 ^ 17: 7.999999874454e+17
8 * 10 ^ 18: 7.999999874454e+18
8 * 10 ^ 19: 7.99999998440516e+19
8 * 10 ^ 20: 8.00000016032702e+20
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Lo que ves es completamente normal &#8211; y no privativo de Python:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">$ perl <span style="color: #339933;">-</span>e <span style="color: #ff0000;">'print unpack(&quot;f&quot;, pack(&quot;f&quot;, 0.8))'</span>
<span style="color: #cc66cc;">0.8000000119209290</span></pre></div></div>

<p>¿Por qué? Porque estás hablando de punto flotante. La aritmética de punto flotante te da gran flexibilidad en el rango en el cual puedes operar (porque no guarda la cantidad tal cual, sino que la cantidad y su magnitud), pero pierde precisión en los dígitos menos significativos. Vamos, igual que con 0.8, esto podrías haberlo visto con números muy grandes:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">$ perl <span style="color: #339933;">-</span>e <span style="color: #ff0000;">'for my $exp (-10..20) {print &quot;8 * 10 ^ $exp: &quot;, unpack(&quot;f&quot;, pack(&quot;f&quot;, 8*10**$exp)),&quot;\n&quot;}'</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">:</span> 8<span style="color: #339933;">.</span>00000010681146e<span style="color: #339933;">-</span>10
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #339933;">:</span> 7<span style="color: #339933;">.</span>99999977374455e<span style="color: #339933;">-</span>09
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">:</span> 7<span style="color: #339933;">.</span>99999995138023e<span style="color: #339933;">-</span>08
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">7</span><span style="color: #339933;">:</span> 8<span style="color: #339933;">.</span>00000009348878e<span style="color: #339933;">-</span>07
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">6</span><span style="color: #339933;">:</span> 7<span style="color: #339933;">.</span>99999997980194e<span style="color: #339933;">-</span>06
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">:</span> 7<span style="color: #339933;">.</span>999999797903e<span style="color: #339933;">-</span>05
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">0.0007999999797903</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">0.00800000037997961</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">0.0799999982118607</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">0.800000011920929</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">8</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">80</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">800</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">8000</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">80000</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">800000</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">8000000</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">7</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">80000000</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">800000000</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">9</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">8000000000</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">80000000000</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">799999983616</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">12</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">7999999967232</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">13</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">79999998623744</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">14</span><span style="color: #339933;">:</span> <span style="color: #cc66cc;">800000003014656</span>
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">15</span><span style="color: #339933;">:</span> 7<span style="color: #339933;">.</span>99999989592883e<span style="color: #339933;">+</span>15
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">16</span><span style="color: #339933;">:</span> 8<span style="color: #339933;">.</span>00000021805138e<span style="color: #339933;">+</span>16
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">17</span><span style="color: #339933;">:</span> 7<span style="color: #339933;">.</span>999999874454e<span style="color: #339933;">+</span>17
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">18</span><span style="color: #339933;">:</span> 7<span style="color: #339933;">.</span>999999874454e<span style="color: #339933;">+</span>18
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">19</span><span style="color: #339933;">:</span> 7<span style="color: #339933;">.</span>99999998440516e<span style="color: #339933;">+</span>19
<span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">^</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">:</span> 8<span style="color: #339933;">.</span>00000016032702e<span style="color: #339933;">+</span>20</pre></div></div>

]]></content:encoded>
	</item>
</channel>
</rss>

