how to read floating point number from a file
how to read floating point number from a file
(OP)
hi, im trying to read a database file from a specific non comercial software. I already decoded the parts I need. There are some double precision float numbers that I want to read. I used:
read(FILE,$number,8);
since I supposed the perl doubles are 64bit long.
The point is that when I print the variable $number, perl treats it like a string instead of as a number. Does any body knows a trick to do this? or I should use C++ or another more powerful language in low level operations.
Thank you for your help
Xavier Maurer
read(FILE,$number,8);
since I supposed the perl doubles are 64bit long.
The point is that when I print the variable $number, perl treats it like a string instead of as a number. Does any body knows a trick to do this? or I should use C++ or another more powerful language in low level operations.
Thank you for your help
Xavier Maurer
RE: how to read floating point number from a file
prompt> perldoc -f unpack
to see how to read a file that is a binary file, this may help you. Otherwise, I think you're reading 8 ascii characters, which is not what you want to do. You want to read the bytes as a nubmer, whcih unpack lets you specify.
As always, I hope that helped!
Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
RE: how to read floating point number from a file
Sincerely,
Tom Anderson
CEO, Order amid Chaos, Inc.
http://www.oac-design.com