Hallo RakonDark,
Es gibt also wohl Dateiformate, bei denen negative Werte
vorgesehen sind, richtig?
??? wie datei formate ???
naja, *.avi, *.bmp, *.xls usw.
Ich glaub bei dir ist irgentwie der zahlenbereich nicht
richtig definiert. Also deine Logik lässt wohl keine negativen
zahlen zu und schreibt bzw liest nur im positiven Bereich.
Aktuell habe ich im Code nur positive Zahlen, das ist schon so. Klappt ja auch viel besser.
Du kannst den code gern posten,
bitte, ist unten angehaengt.
aber ich glaub bei dir fehlt
einfach nur grundwissen
Uuuh, das weiss ich alles. Das Problem ist: ich kriege die negative Zahlen falsch retour.
lg
Martin B
////////////////////////////////////
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
char buf[256];
#define LOG\_DATEI ("app.log")
template
class Vector
{
std::vector v;
int i;
int size;
public:
Vector() : i(0), size(0)
{}
Vector& operator BIN\_UCHAR\_STACK;
#define FLOAT\_FACTOR 10000
ULONG getFileSize(FILE \*fpIn)
{
fseek(fpIn, 0, SEEK\_END);
ULONG fileSize = ftell (fpIn);
fseek(fpIn, 0, SEEK\_SET);
return (ULONG)fileSize;
}
class BinaryWriter
{
public:
BinaryWriter(bool littleEndian);
~BinaryWriter();
long getSize() {return Keep.getSize();}
void setValue(ULONG &temp, uchar which, ULONG wert);
// Anwender muss die Zahl bitweise auf "ULONG num" kopieren...
// "ULONG lo = -24;" würde heissen, das '-' kommt ganz links hin...!
// "num" wird nachher auf Null zurueckgesetzt.
int integer(ULONG &num, int numBytes);
int double\_(double &dou);
BinaryWriter& operator 4) ? (4) : (numBytes);
ULONG mask;
if (littleEndian)
{
shifter = 0;
for (i=0; i \> shifter);
Keep -1; i--, shifter-=8)
{
mask = (0xff \> shifter);
Keep integer (num, 4);
num |= (diff);
this-\>integer (num, 4);
return 0;
}
BinaryWriter& BinaryWriter::operator \> (uchar uch);
};
BinaryParser::BinaryParser(CC file, bool littleEndian\_) :
// data (openFile(file, 0, "rb")),
data (0),
littleEndian (littleEndian\_),
i (0),
fileSize(0)
{
FILE \*bin = fopen(file, "rb");
fileSize = getFileSize(bin);
data = new uchar[fileSize + 2];
assert (data);
fread(data, sizeof(char), fileSize, bin);
data[fileSize + 1] = 0;
if (2 cout fertig." \> (uchar uch)
{
uch = data[i++];
return \*this;
}
int BinaryParser::someChars(std::string &get, const int numBytes)
{
get.erase();
for (int j=0; j 4) ? (4) : (numBytes);
num = 0;
if (littleEndian)
{
shifter = 0;
for (j=0; j -1; i++, j--, shifter-=8)
{
uch = data[i];
if (uch) {num |= (uch integer(ul, 4);
dou += ul;
// the floats:
this-\>integer(ul, 4);
dou += ul / FLOAT\_FACTOR;
return 0;
}
//////////////////////////////////////////
// bin\_pars.cpp
class Punkt
{
public:
long x, y;
Punkt() {}
Punkt(long x\_, long y\_) : x(x\_), y(y\_) {}
Punkt(LPARAM l) : x(l & 0xFFFF), y((l & 0xFFFF0000) \>\> 16) {}
// int getBinaryLen() {return 4;}
int getBinaryData(BinaryWriter &Bywr)
{
// schreibt zwei UINT's:
ULONG u = 0;
u |= x; // copy
// OK, da muss ich noch "ausmisten, :smile:"
if (x = -128) {u &= ~(0xffffff = -128) {u &= ~(0xff x y