Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Reading IEEE float values from files.

  1. #1
    Junior Member
    Join Date
    Jun 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Reading IEEE float values from files.

    FileInputSream, BufferedInputStream
    FileReader, BufferedReader

    These classes AFAIK only have read methods which return strings, char arrays or byte arrays, or single bytes. The problem is if I want to read 2 byte floats or 4 byte double precision IEEE floating point numbers, how do I read them and use them in java?? I really don't to read these byte by byte and have to do manual binary number manipulation and reading.

    Thanks for reading! Thanks for helpful comments in advance!


  2. #2
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: Reading IEEE float values from files.

    Read them into a string then use

    double myDouble = Double.valueOf(theString);

    Regards,
    Chris

  3. #3
    Junior Member
    Join Date
    Jun 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Reading IEEE float values from files.

    I tried this but it only seems to read the number as the ascii representation not the actual value, ie. it reads 0x3132 as 12 from the ascii character for 0x31 for 2 and the ascii character for 0x32 is 2, but what I need is the actual number (IEEE integer) as in 0x3132 is 12849.

  4. #4
    Junior Member
    Join Date
    Jun 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Reading IEEE float values from files.

    Nvm I found the answer, DataInputStream lets you read all data types including unsigned values. Except I still don't know how to handle big-endian little-endianess.
    Last edited by username9000; June 30th, 2009 at 02:12 PM.

Similar Threads

  1. Replies: 1
    Last Post: December 22nd, 2011, 09:55 AM
  2. [SOLVED] Using 3rd Party JAR Files
    By oss_2008 in forum Java Theory & Questions
    Replies: 12
    Last Post: June 12th, 2009, 10:27 AM
  3. How to check that console input should be integer only?
    By Konnor in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: February 2nd, 2009, 05:37 AM
  4. Java program to find the minimum and maximum values of input data
    By awake77 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: December 20th, 2008, 05:12 PM
  5. How to convert float and double data types to binary?
    By rosh72851 in forum Java Theory & Questions
    Replies: 1
    Last Post: October 7th, 2008, 10:45 PM