Getting binary data

Hi,

I've got a file that has some floats and ints at the beginning of the
file. The floats were added to the file with code like:

fprintf(file_ptr, "%f %f\n", some_float_1, some_float_2);
fprintf(file_ptr, "%f %f\n", some_float_3, some_float_4);
fprintf(file_ptr, "%d %d\n", some_int_1, some_int_2);
fprintf(file_ptr, "%d %d\n", some_int_3, some_int_4);

But I'm having the hardest time using unpack() to get the data. Any pointers?

Joe

That doesn't sound like binary data to me. For example, this C
program:

    #include "stdio.h"
    int main() {
        float some_float_1 = 42e23, some_float_2 = 23.42;
        printf("%f %f\n", some_float_1, some_float_2);
        return 0;
    }

Produces:

    4199999942871246500000000.000000 23.420000

If that's the case, something like this might answer:

    filename = "data.txt"
    IO.foreach(filename) { |line|
        a = line.split
        x = a[0].to_f
        y = a[1].to_f

        puts "x = #{x}, y = #{y}"
        }

-- Timothy