jeudi 6 juillet 2017

Random numbers file for Diehard test (run-time error F6501: READ(camdie) - end of file encountered)

I want to use Diehard test for testing my random number generator. I have file with random numbers (0-9)

For example:

27709262113634443297

I need convert this numbers to format accepted by ASC2BIN program for use Dieharder from Dieharder homepage for Windows. Instructions are:

You must first create the ascii file. To do that, generate your 32-bit integers and write them to a file, in hex format, 80 characters (ten 32-bit integers) per line.

So I've written Java app:

BufferedReader br;
    FileReader fr;
    PrintWriter wr;
    final int numberToLine = 10;

    try {
        fr = new FileReader("C:\\dpdata\\generated_values_camera_1488712636551.txt");
        br = new BufferedReader(fr);
        wr = new PrintWriter("C:\\dpdata\\camera_diehard");

        int number;
        int wrote = 0;

        while((number = br.read()) != -1){
            int hexadecimal = Integer.valueOf(String.valueOf((char)number), 16); //prevod na hexadecimalni cislo
            String eightBit = String.format("%08d", hexadecimal); // 8bit zapis

            wr.write(eightBit);
            System.out.print(eightBit);
            wrote++;

            if(wrote == numberToLine){
                wr.write("\n");
                System.out.print("\n");
                wrote = 0;
            }
        }

        wr.close();
        br.close();
        fr.close();

So I have file camdie with this:

00000002000000070000000700000000000000090000000200000006000000020000000100000001
00000003000000060000000300000004000000040000000400000003000000020000000900000007

But ASC2BIN write

run-time error F6501: READ(camdie) - end of file encountered

What do you thing that is wrong? I have 10 hexadecimal numbers per line, each have 8 bit. ASC2BIN is wrote in Fortran and I think that problem is in file format, but I don't know where.




Aucun commentaire:

Enregistrer un commentaire