Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

how to read floating point number from a file

how to read floating point number from a file

how to read floating point number from a file

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:


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

Check out perl's

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!

Beware: Studies have shown that research causes cancer in lab rats.

RE: how to read floating point number from a file

I would argue that Perl is more powerful than C++.  Also, if you prefer to use C code, then you can do so directly in your Perl script... it passes it to your compiler.  Check the perldocs.

Tom Anderson
CEO, Order amid Chaos, Inc.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close