2
$\begingroup$
testList = {1, 2, 3, 4};
file = "test1";
BinaryWrite[file, testList];
BinaryReadList[file]
Close[file];

Gives

{1, 2, 3, 4}

Cool... but

testList = {1, 2, 3, -4};
file = "test1";
BinaryWrite[file, testList];
BinaryReadList[file]
Close[file];

Results in

BinaryWrite::nocoerce: -4 cannot be coerced to the specified format. >>

I have to Read and Write Data files that are 5GB large and they have pos and negativ values. Is there a work around?

$\endgroup$

closed as off-topic by MarcoB, dr.blochwave, Mr.Wizard Jul 15 '15 at 9:03

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, dr.blochwave, Mr.Wizard
If this question can be reworded to fit the rules in the help center, please edit the question.

4
$\begingroup$

The default type is an unsigned integer. You need to specify a suitable type, eg:

testList = {1, 2, 3, -4};
file = "test1";
BinaryWrite[file, testList, "Integer8"];
BinaryReadList[file, "Integer8"]
Close[file];

Note the read needs to know the type as well. See BinaryRead for the list of types. (Integer8 is only good for values in the range -128 to 127 of course )

$\endgroup$
  • $\begingroup$ Do you know whats the identifier for double? $\endgroup$ – newandlost Jul 14 '15 at 14:58
  • $\begingroup$ Just found it... "Real64" Thanks! $\endgroup$ – newandlost Jul 14 '15 at 14:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.