[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] newbie question: binary file manipulation



> For example, I would like to convert line input :
>
>x = 12.1 y = 13.4
>
>in the binary form
>XXXX YYYY (float on 4 bytes)

I read that you want to convert **TO**  XXXX YYYY as two successive 4 
byte IEEE single floating point numbers in binary on the output file.

I think the "pack" suggestions of others will put out 8 byte doubles.

I also think you should think about what you're trying to do. The 
file in IEEE singles will be quite machine specific because of byte 
ordering. It may also be less efficient in storage unless your 
coordinates really have a spectacular range of values.

Fixed point binary unsigned chars would be enough to save what you 
show above. Even three byte ASCII with the decimal suppressed would 
be smaller and more transportable than the floats. 16 bit integers 
are another option but would also introduce the byte ordering problem.

Why floats?

-> From the U S of A, the only socialist country that refuses to admit it. <-

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org