Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #3339

BUG: binary data is not being interpreted correctly

Newsgroups comp.graphics.apps.gnuplot
Date 2016-06-10 17:11 -0700
Message-ID <aa0d5af4-e41e-4e11-8eb2-3549bd29aea2@googlegroups.com> (permalink)
Subject BUG: binary data is not being interpreted correctly
From adrian.hawryluk@gmail.com

Show all headers | View raw


I create a small binary file and it is ok, but when the binary file gets to a certain size, it goes all wonky.  Here is a C++ binary file generator:

#include <limits>
#include <iostream>
#include <assert.h>

template <typename T1, typename T2>
void write(std::ostream& os, T1 x, T2 y)
{
	using namespace std;
	static int counter = 0;
	assert(0 <= x);
	assert(0 <= y);
	assert(x < numeric_limits<double>::max());
	assert(y < numeric_limits<double>::max());
	double array[2] = { (double)x, (double)y };
	os.write((char*)array, sizeof(array));
	os.flush();
	++counter;
}

int main()
{
	using namespace std;
	ofstream os;
	os.open("data.dat");
	uint64_t y_value = 0;
	for (uint64_t x_value = 0; x_value < 5000; ++x_value)
	{
		write(os, x_value, y_value);
		if (x_value % 10 == 0)
		{
			++y_value;
		}
	}
	return 0;
}

It just creates a stepping function, increasing 1 every 10.  I then read the file using the command:

plot 'data.dat' binary format='%lf%lf' 0:1

If I read the file before it gets too big, I get an increasing stepping function.  If I get to around 2000, I get some negative values.

Back to comp.graphics.apps.gnuplot | Previous | NextNext in thread | Find similar


Thread

BUG: binary data is not being interpreted correctly adrian.hawryluk@gmail.com - 2016-06-10 17:11 -0700
  Re: BUG: binary data is not being interpreted correctly Jack Adrian Zappa <adrian.hawryluk@gmail.com> - 2016-06-10 19:08 -0700

csiph-web