# BinaryWrite negative numbers [closed]

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


Gives

{1, 2, 3, 4}


Cool... but

testList = {1, 2, 3, -4};
file = "test1";
BinaryWrite[file, testList];
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?

## 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.

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"];

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 )