<div dir="ltr">You may be able to avoid endian-ness issues by using BitConverter.ToDouble with a byte array instead. (I'm never sure how endian-ness and IEEE-754 interact.)</div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, May 8, 2013 at 9:06 AM, Markus Schaber <span dir="ltr"><<a href="mailto:m.schaber@codesys.com" target="_blank">m.schaber@codesys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">






<div lang="DE" vlink="purple" link="blue">
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif";font-size:10pt">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif";font-size:10pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif";font-size:10pt">I tried to find a way to calculate it reliably, but did not find an easy, nice and fast way.<u></u><u></u></span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif";font-size:10pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif";font-size:10pt">I guess setting the IEC bits directly is the best way for now, together with a comment why we don't use the false friends provided by .NET.<u></u><u></u></span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif";font-size:10pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif";font-size:10pt">However, as far as I read the docs of DoubleToInt64Bits() and Int64BitsToDouble(), the conversion may be subject to endianess issues…<u></u><u></u></span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif";font-size:10pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif";font-size:10pt">Best regards<br>
<br>
Markus Schaber</span><span lang="EN-US"><br>
<br>
</span><b><span lang="EN-US" style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:10pt">CODESYS<sup>®</sup></span></b><span lang="EN-US">
</span><span lang="EN-US" style="color:rgb(177,178,179);font-family:"Arial","sans-serif";font-size:8pt">a trademark of 3S-Smart Software Solutions GmbH</span><span lang="EN-US">
<br>
</span><b><span lang="EN-US" style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:2pt"><br>
</span></b><b><span lang="EN-US" style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:10pt">Inspiring Automation Solutions
</span></b><span lang="EN-US" style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:10pt"><u></u><u></u></span></p>
<div class="MsoNormal"><span style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:10pt">
<hr width="636" size="1" align="left" style="width:477pt" noshade>
</span></div>
<p class="MsoNormal"><span lang="EN-US" style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:10pt">3S-Smart Software Solutions GmbH
<br>
Dipl.-Inf. Markus Schaber | Product Development Core Technology <br>
Memminger Str. 151 | 87439 Kempten | Germany <br>
Tel. <a href="tel:%2B49-831-54031-979" target="_blank" value="+4983154031979">+49-831-54031-979</a> | Fax <a href="tel:%2B49-831-54031-50" target="_blank" value="+498315403150">+49-831-54031-50</a> <br>
<br>
E-Mail: </span><span style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:10pt"><a href="mailto:m.schaber@codesys.com" target="_blank"><span lang="EN-US" style="color:rgb(227,0,15);text-decoration:none">m.schaber@codesys.com</span></a></span><span lang="EN-US" style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:10pt">
 | Web: </span><span style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:10pt"><a href="http://www.codesys.com" target="_blank"><span lang="EN-US" style="color:rgb(227,0,15);text-decoration:none">codesys.com</span></a></span><span lang="EN-US" style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:10pt">
 | CODESYS store: </span><span style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:10pt"><a href="http://store.codesys.com" target="_blank"><span lang="EN-US" style="color:rgb(227,0,15);text-decoration:none">store.codesys.com</span></a></span><span lang="EN-US" style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:10pt">
<br>
CODESYS forum: </span><span style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:10pt"><a href="http://forum.codesys.com" target="_blank"><span lang="EN-US" style="color:rgb(227,0,15);text-decoration:none">forum.codesys.com</span></a></span><span lang="EN-US" style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:10pt">
<br>
<br>
</span><i><span lang="EN-US" style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:8pt">Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner</span></i><span lang="EN-US" style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:8pt">
 | <i>Trade register: Kempten HRB 6186</i> | <i>Tax ID No.: DE 167014915</i></span><b><span lang="EN-US" style="color:rgb(99,99,99);font-family:"Arial","sans-serif";font-size:10pt">
</span></b><span lang="EN-US" style="font-family:"Arial","sans-serif";font-size:10pt"><u></u><u></u></span></p>
<div style="border-width:medium medium medium 1.5pt;border-style:none none none solid;border-color:currentColor currentColor currentColor blue;padding:0cm 0cm 0cm 4pt">
<div>
<div style="border-width:1pt medium medium;border-style:solid none none;border-color:rgb(181,196,223) currentColor currentColor;padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span style="font-family:"Tahoma","sans-serif";font-size:10pt">Von:</span></b><span style="font-family:"Tahoma","sans-serif";font-size:10pt"> Curt Hagenlocher [mailto:<a href="mailto:curt@hagenlocher.org" target="_blank">curt@hagenlocher.org</a>]
<br>
<b>Gesendet:</b> Mittwoch, 8. Mai 2013 17:34<br>
<b>An:</b> Jeff Hardy<br>
<b>Cc:</b> Markus Schaber; <a href="mailto:ironpython-users@python.org" target="_blank">ironpython-users@python.org</a><br>
<b>Betreff:</b> Re: [Ironpython-users] IronPython float_info values (was: IronPython always in 32-bit mode on 64bit machine even when running ipy64.exe)<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">You can get precise values of these without depending on the compiler's ability to convert text to floating point values by saying<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">sys.float_info.min = System.BitConverter.Int64BitsToDouble(0x0010000000000000)  # i.e. 2^-1023<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">sys.float_info.epsilon = System.BitConverter.Int64BitsToDouble(0x3cb0000000000000) # i.e. 2^-53<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12pt"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Wed, May 8, 2013 at 8:10 AM, Jeff Hardy <<a href="mailto:jdhardy@gmail.com" target="_blank">jdhardy@gmail.com</a>> wrote:<u></u><u></u></p>
<div>
<p class="MsoNormal">On Wed, May 8, 2013 at 4:07 AM, Markus Schaber <<a href="mailto:m.schaber@codesys.com" target="_blank">m.schaber@codesys.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<blockquote style="border-width:medium medium medium 1pt;border-style:none none none solid;border-color:currentColor currentColor currentColor rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-right:0cm;margin-left:4.8pt">

<div>
<div>
<p><span style="font-family:"Arial","sans-serif";font-size:10pt">Hi,</span><u></u><u></u></p>
<p><span style="font-family:"Arial","sans-serif";font-size:10pt"> </span><u></u><u></u></p>
<p><span style="font-family:"Arial","sans-serif";font-size:10pt"><a href="http://www.johndcook.com/blog/2010/06/08/c-math-gotchas/" target="_blank"><span lang="EN-US">http://www.johndcook.com/blog/2010/06/08/c-math-gotchas/</span></a></span><span lang="EN-US" style="font-family:"Arial","sans-serif";font-size:10pt">
 explains the problem: The double.MinValue and double.Epsilon in C# have different meanings thant DBL_MIN and DBL_EPSILON in C.</span><u></u><u></u></p>
<p><span lang="EN-US" style="font-family:"Arial","sans-serif";font-size:10pt"> </span><u></u><u></u></p>
<p><span lang="EN-US" style="font-family:"Arial","sans-serif";font-size:10pt">I'm looking for a way how to get the wanted values…
</span><span lang="EN-US" style="font-family:Wingdings;font-size:10pt">J</span><u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">So am I! .NET does not provide them as constants as far as I can tell. I'm pretty sure .NET requires the use of IEEE-854 floats so they could probably just be hardcoded to match the C constants but ... ick. Maybe there's a way to calculate
 the C versions from what .NET provides?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">The relevant issue is <a href="https://ironpython.codeplex.com/workitem/27840" target="_blank">https://ironpython.codeplex.com/workitem/27840</a>. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="color:rgb(136,136,136)"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:rgb(136,136,136)">- Jeff<u></u><u></u></span></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12pt"><br>
_______________________________________________<br>
Ironpython-users mailing list<br>
<a href="mailto:Ironpython-users@python.org" target="_blank">Ironpython-users@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/ironpython-users" target="_blank">http://mail.python.org/mailman/listinfo/ironpython-users</a><u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</div>

</blockquote></div><br></div>