written in all of the memory cells the u201c 00 u201d counter 50 counts u201c 00 u201d of the minimum threshold value when the count value of the u201c 00 u201d counter 50 is equal to or larger than half the value of the total number of the cells with msb being 1 u201c h u201d is written when the count value of the u201c 00 u201d counter 50 is less than half the total number of the cells with msb being 0 u201c l u201d is written in the memory unit 14 via the selector 110 the data conversion unit 13 converts u201c 00 u201d in the write data to u201c 10 u201d of the maximum threshold value and shifts the others to the higher values when the data of the memory unit 14 is u201c l u201d the data is outputted unchanged according to the present embodiment the logic inversion is executed when the count value of the minimum threshold bit string is equal to or larger than half the value of the total numbers of the cells therefore the data retention characteristic can be statistically improved in the present embodiment the array 10 may be divided into a plurality of sub arrays as shown in fig1 to thereby execute the data conversion per sub array as in the previous embodiments the selector 110 u201c 00 u201d counter 50 and u201c 10 u201d counter 52 in an area below a dotted line are not necessarily disposed in the present memory device and may be disposed in an external apparatus such as.