<?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[IO (plattform unabhängig)]]></title><description><![CDATA[<p>Hallo, ich habe folgendes Problem,<br />
ich ziemlich oft arrays von double auslesen, und schreiben.<br />
Zur Zeit mache ich das über streams als strings, das funktioniert auch gut,<br />
macht aber keinen spass mehr, wenn die dateien ca 1GB gross werden.</p>
<p>Kennt wer eine Seite wo man nachlesen kann, wie man am besten<br />
double nach char* umwandelt, und umgekehrt, damit ich das ganze im<br />
binär-format abspeichern kann?<br />
Das würde nämlich jede Menge Ladezeit sparen.</p>
<p>Danke im Vorraus.<br />
Das Problem ist nur das sizeof(double) ständig schwankt, geringer datenverlust<br />
würde mich nicht stören (zB 64bit double als 32bit abspeichern, und dann wieder als 32bit laden)</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/198431/io-plattform-unabhängig</link><generator>RSS for Node</generator><lastBuildDate>Fri, 02 Oct 2026 06:43:07 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/198431.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 21 Nov 2007 14:51:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to IO (plattform unabhängig) on Wed, 21 Nov 2007 14:51:47 GMT]]></title><description><![CDATA[<p>Hallo, ich habe folgendes Problem,<br />
ich ziemlich oft arrays von double auslesen, und schreiben.<br />
Zur Zeit mache ich das über streams als strings, das funktioniert auch gut,<br />
macht aber keinen spass mehr, wenn die dateien ca 1GB gross werden.</p>
<p>Kennt wer eine Seite wo man nachlesen kann, wie man am besten<br />
double nach char* umwandelt, und umgekehrt, damit ich das ganze im<br />
binär-format abspeichern kann?<br />
Das würde nämlich jede Menge Ladezeit sparen.</p>
<p>Danke im Vorraus.<br />
Das Problem ist nur das sizeof(double) ständig schwankt, geringer datenverlust<br />
würde mich nicht stören (zB 64bit double als 32bit abspeichern, und dann wieder als 32bit laden)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1407406</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1407406</guid><dc:creator><![CDATA[Treb]]></dc:creator><pubDate>Wed, 21 Nov 2007 14:51:47 GMT</pubDate></item><item><title><![CDATA[Reply to IO (plattform unabhängig) on Wed, 21 Nov 2007 15:04:19 GMT]]></title><description><![CDATA[<blockquote>
<p>Kennt wer eine Seite wo man nachlesen kann, wie man am besten<br />
double nach char* umwandelt, und umgekehrt, damit ich das ganze im<br />
binär-format abspeichern kann?</p>
</blockquote>
<p>Versteh ich nicht. Du kannst jeden beliebigen Datentyp im Binärformat abspeichern, dazu bedarf es keiner Zeichenkette o.Ä..</p>
<blockquote>
<p>Das Problem ist nur das sizeof(double) ständig schwankt, geringer datenverlust<br />
würde mich nicht stören (zB 64bit double als 32bit abspeichern, und dann wieder als 32bit laden)</p>
</blockquote>
<p>Meinst du, die Größe eines doubles ändert sich auf einer anderen Platform? Das ist kein Problem. Entweder du bedienst dich an den platformunabhängigen Datentypen aus der Boost-Library, oder bastelst dir z.B. deinen platformunabhängigen Datentyp selber, wie hier als Beispiel näher gebracht (es handelt sich um einen Integer, lässt sich aber problemlos als Templateklasse implementieren):</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

typedef unsigned char My32BitInteger[4];

class MyInteger
{
    private:
        My32BitInteger myInt;

    public:
        // Konvertierungsoperator
      operator int();
    // Standardkonstruktor
    MyInteger()
    {
        cout &lt;&lt; &quot;Standardkonstruktor&quot; &lt;&lt; endl;
        myInt[0] = 0;
        myInt[1] = 0;
        myInt[2] = 0;
        myInt[3] = 0;
    }

    // Konvertierungskonstruktor
    MyInteger( int i )
    {
        cout &lt;&lt; &quot;Konvertierungskonstruktor&quot; &lt;&lt; endl;
        myInt[0] = *( reinterpret_cast &lt;char*&gt; (&amp;i)   );
        myInt[1] = *( reinterpret_cast &lt;char*&gt; (&amp;i)+1 );
        myInt[2] = *( reinterpret_cast &lt;char*&gt; (&amp;i)+2 );
        myInt[3] = *( reinterpret_cast &lt;char*&gt; (&amp;i)+3 );
    }
};

// Konvertierungsoperator
MyInteger:: operator int()
{
     cout &lt;&lt; &quot;Konvertierungsoperator &quot; &lt;&lt; endl;
    return     *(reinterpret_cast &lt;unsigned*&gt; (myInt));
}

int main()
{
    // Konvertierungskonstruktor
    MyInteger my_int( 77777777 );
    cout &lt;&lt; my_int &lt;&lt; endl;
    // Standardkonstruktor
     MyInteger my_integer;
    // Konvertierungsoperator
      int i = my_integer;
    cout &lt;&lt; i &lt;&lt; endl;
    my_integer = my_int;
    cout &lt;&lt; my_integer &lt;&lt; endl;
    getchar ();
}
</code></pre>
<p>In dem Beispiel ist der Integer also auf jeder Platform 32 Bit groß.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1407420</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1407420</guid><dc:creator><![CDATA[mikey]]></dc:creator><pubDate>Wed, 21 Nov 2007 15:04:19 GMT</pubDate></item><item><title><![CDATA[Reply to IO (plattform unabhängig) on Wed, 21 Nov 2007 15:23:07 GMT]]></title><description><![CDATA[<p>dann werde ich um boost wohl nicht rumkommen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>ich weiss schon, das man sowas in etwa so schreiben würde, wie du es aufgezeigt hast, mein problem ist eher, das ich nicht genau weiss, wie ich die konvertierungsoperatoren schreiben soll, du machst ja auch die annahme das<br />
sizeof(int) == 4</p>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox21500" checked="true" /><label for="checkbox21500">(wobei x am besten 8)und zurück, ich habe schon dran gedacht, einen double einfach als 2 ints (vor und nach dem komma) darzustellen, denn mit ints platform-unabhängig zu arbeiten ist immernoch einfacher als mit doubles//floats</label></div></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1407439</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1407439</guid><dc:creator><![CDATA[Treb]]></dc:creator><pubDate>Wed, 21 Nov 2007 15:23:07 GMT</pubDate></item><item><title><![CDATA[Reply to IO (plattform unabhängig) on Wed, 21 Nov 2007 15:41:52 GMT]]></title><description><![CDATA[<p>sizeof(double)???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1407459</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1407459</guid><dc:creator><![CDATA[sizeof]]></dc:creator><pubDate>Wed, 21 Nov 2007 15:41:52 GMT</pubDate></item><item><title><![CDATA[Reply to IO (plattform unabhängig) on Wed, 21 Nov 2007 15:59:51 GMT]]></title><description><![CDATA[<p>ich werde wohl den traum von :<br />
&quot; schreibe double in bin-file auf 32bit-windows, und<br />
lese die datei in 64bit-linux&quot; verwerfen.</p>
<p>Mir reichts eigentlich auch, wenn die dateien nur auf der selben<br />
Platform lesbar sind.</p>
<p>und dann geht das ja auch ziemlich einfach mit sizeof() und rumcasten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1407485</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1407485</guid><dc:creator><![CDATA[Treb]]></dc:creator><pubDate>Wed, 21 Nov 2007 15:59:51 GMT</pubDate></item><item><title><![CDATA[Reply to IO (plattform unabhängig) on Wed, 21 Nov 2007 17:14:08 GMT]]></title><description><![CDATA[<p>Ein double sollte aber bei den meisten (heutigen) Compilern immer 8 Bytes entsprechen, d.h. das hat nichts mit der Prozessordatenbreite zu tun (32 oder 64 Bit).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1407569</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1407569</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Wed, 21 Nov 2007 17:14:08 GMT</pubDate></item><item><title><![CDATA[Reply to IO (plattform unabhängig) on Thu, 22 Nov 2007 00:16:31 GMT]]></title><description><![CDATA[<blockquote>
<p>ich werde wohl den traum von :<br />
&quot; schreibe double in bin-file auf 32bit-windows, und<br />
lese die datei in 64bit-linux&quot; verwerfen.</p>
</blockquote>
<p>Wieso verwerfen? Wozu halten sich wohl (sogut wie) alle an den IEEE 754 Standard?<br />
Ist in C++ IEEE 754 nicht sogar vorgeschrieben (double und float)?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1407865</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1407865</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Thu, 22 Nov 2007 00:16:31 GMT</pubDate></item></channel></rss>