<p>Yes, GCC and Visual Studio C++ have different <code>long double</code> types. On GCC generating code for x86, <code>long double</code> is a 80-bit double-extended IEEE 754 format(*), whereas Visual Studio C++ treats <code>long double</code> like a 64-bit double-precision IEEE 754 format(**).</p>
<p>So <code>(long double)t</code> does not have to be the same number on both platforms, and the division is not the same either. Although you have tagged your question “integer-division”, it is a floating-point division between different floating-point types.</p>
<p>(*) almost: it behaves very very much like a 79-bit <a href="http://en.wikipedia.org/wiki/IEEE_754-1985" rel="nofollow noreferrer">IEEE 754</a> type with 15 exponent bits and 63 significand bits would, but it has a slightly wider exponent range since it uses an explicit bit for the leading 1 in the significand.</p>
<p>(**) almost: because the compiler generates instructions that use the historical x87 instructions after having configured the x87 for 53-bit significands, denormal results may be double-rounded (<a href="http://arxiv.org/abs/cs/0701192" rel="nofollow noreferrer">reference</a>).</p>
Same calculation on Linux and Windows --> different results
<p>I have coded following algorithm to convert a decimal value into Binary/Hexadecimal etc..</p>

<pre><code>string toFormatFromDecimal(long long t, Format format) {
    int digitCount = ceil(log(t) / log((int) format));
    string hex = "";
    for (int i = 0; i &lt; digitCount; i++) {
        long double cur = (long double)t / (long double)(format);
        long long ganzzahl = (long long) cur;
        long double kommazahl = cur - ganzzahl;
        hex += digits[(long long) (kommazahl * format)];
        t = ganzzahl;
    }
    return string(hex.rbegin(), hex.rend());
}
</code></pre>

<p>I use GCC in linux and Visual Studio c++ compiler on Windows
It seems that i got different values at the "integer" Division here:</p>

<pre><code>long long ganzzahl = (long long) cur;
</code></pre>

<p>Any Idea how this could happen? are there different precissions on Linux and Windows?</p>

<p>Thanks
Florian</p>

<p>--Solution--</p>

<pre><code>string toFormatFromDecimal(long long t, Format format) {
    int digitCount = ceil(log(t) / log((int) format));
    string hex = "";
    for (int i = 0; i &lt; digitCount; i++) {
        hex += digits[(int) (t%format)];
        t = t/format;
    }
    return string(hex.rbegin(), hex.rend());
}
</code></pre>