<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[long long und double größe]]></title><description><![CDATA[<p>Hi,</p>
<p>kann mir jemand sagen ob double und long long immer die gleiche größe haben ?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/298424/long-long-und-double-größe</link><generator>RSS for Node</generator><lastBuildDate>Thu, 13 Aug 2026 21:31:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/298424.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 19 Jan 2012 18:53:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to long long und double größe on Thu, 19 Jan 2012 18:53:30 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>kann mir jemand sagen ob double und long long immer die gleiche größe haben ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2170183</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2170183</guid><dc:creator><![CDATA[pyhax]]></dc:creator><pubDate>Thu, 19 Jan 2012 18:53:30 GMT</pubDate></item><item><title><![CDATA[Reply to long long und double größe on Thu, 19 Jan 2012 18:55:44 GMT]]></title><description><![CDATA[<p>Nein, das ist nicht garantiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2170185</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2170185</guid><dc:creator><![CDATA[SG1]]></dc:creator><pubDate>Thu, 19 Jan 2012 18:55:44 GMT</pubDate></item><item><title><![CDATA[Reply to long long und double größe on Thu, 19 Jan 2012 19:09:38 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">// Initial AlmostEqualULPs version - fast and simple, but

// some limitations.

bool AlmostEqualUlps(float A, float B, int maxUlps)

{

    assert(sizeof(float) == sizeof(int));

    if (A == B)

        return true;

    int intDiff = abs(*(int*)&amp;A - *(int*)&amp;B);

    if (intDiff &lt;= maxUlps)

        return true;

    return false;

}
</code></pre>
<p>von <a href="http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm" rel="nofollow">http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm</a></p>
<p>Also kann es sein, dass dieser Code (für double müsste ich dann ja long long nehmen, oder?), nicht auf allen Systemen funktioniert? Gibt es da irgendeine Möglichkeit das zu umgehen? Und kennt jemand ein System bei dem sizeof(double)!=sizeof(long long)? (Nicht Embedded)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2170187</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2170187</guid><dc:creator><![CDATA[pyhax]]></dc:creator><pubDate>Thu, 19 Jan 2012 19:09:38 GMT</pubDate></item><item><title><![CDATA[Reply to long long und double größe on Thu, 19 Jan 2012 19:09:20 GMT]]></title><description><![CDATA[<p>pyhax schrieb:</p>
<blockquote>
<p>Also kann es sein, dass dieser Code (für double müsste ich dann ja long long nehmen, oder?), nicht auf allen Systemen funktioniert? Gibt es da irgendeine Möglichkeit das zu umgehen?</p>
</blockquote>
<p>Ja. Geh mit Template-Metaprogrammierung durch eine Typenliste und nimm den ersten, der groß genug ist.<br />
Aber dann haste immernoch das Problem, daß die iunterne Darstellung von ints und von Fließkommazahlen nicht garantiert ist. Also nix gewonnen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2170194</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2170194</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 19 Jan 2012 19:09:20 GMT</pubDate></item><item><title><![CDATA[Reply to long long und double größe on Thu, 19 Jan 2012 19:13:43 GMT]]></title><description><![CDATA[<p>Du könntest mit Boost.Integer den passenden Integer-Typ zur Laufzeit rauskramen. Also:</p>
<pre><code class="language-cpp">template&lt;typename Float&gt;
bool AlmostEqualUlps(Float a, Float b, int maxUlps)
{
    static_assert(std::is_float&lt;Float&gt;::value, &quot;Float expected&quot;);
    typedef boost::int_t&lt;sizeof(Float) * CHAR_BITS&gt;::least integer;
    static_assert(sizeof(integer) == sizeof(Float), &quot;Size mismatch&quot;);

    if(a == b)
        return true;

    int intDiff = std::abs(*(integer*)&amp;a - *(integer*)&amp;b);
    if (intDiff &lt;= maxUlps)
        return true;

    return false;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2170196</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2170196</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Thu, 19 Jan 2012 19:13:43 GMT</pubDate></item><item><title><![CDATA[Reply to long long und double größe on Thu, 19 Jan 2012 19:17:17 GMT]]></title><description><![CDATA[<p>Ethon schrieb:</p>
<blockquote>
<p>Du könntest mit Boost.Integer den passenden Integer-Typ zur Laufzeit rauskramen. Also:</p>
<pre><code class="language-cpp">template&lt;typename Float&gt;
bool AlmostEqualUlps(Float a, Float b, int maxUlps)
{
    static_assert(std::is_float&lt;Float&gt;::value, &quot;Float expected&quot;);
    typedef boost::int_t&lt;sizeof(Float) * CHAR_BITS&gt;::least integer;
    static_assert(sizeof(integer) == sizeof(Float), &quot;Size mismatch&quot;);

    if(a == b)
        return true;

    int intDiff = std::abs(*(integer*)&amp;a - *(integer*)&amp;b);
    if (intDiff &lt;= maxUlps)
        return true;

    return false;
}
</code></pre>
</blockquote>
<p>Wieso zur Laufzeit? Ich sehe da nur typedef's und static_assert's <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2170201</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2170201</guid><dc:creator><![CDATA[pyhax]]></dc:creator><pubDate>Thu, 19 Jan 2012 19:17:17 GMT</pubDate></item><item><title><![CDATA[Reply to long long und double größe on Thu, 19 Jan 2012 19:18:25 GMT]]></title><description><![CDATA[<p>Ehm, zur Compile-Zeit. *Dong...*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2170203</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2170203</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Thu, 19 Jan 2012 19:18:25 GMT</pubDate></item><item><title><![CDATA[Reply to long long und double größe on Thu, 19 Jan 2012 19:28:12 GMT]]></title><description><![CDATA[<p>OK dann ist das genau das was ich suche.</p>
<p>EDIT: Mir ist gerade nochwas aufgefallen (sinnlos, aber was soll's :D)</p>
<pre><code>volatile register const unsigned long long int myConst = 0;
</code></pre>
<p>Woah</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2170206</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2170206</guid><dc:creator><![CDATA[pyhax]]></dc:creator><pubDate>Thu, 19 Jan 2012 19:28:12 GMT</pubDate></item></channel></rss>