User Profile

Collapse

Profile Sidebar

Collapse
tophandasa
tophandasa
Last Activity: Mar 27 '07, 09:19 PM
Joined: Mar 22 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • tophandasa
    replied to Trouble reading a binary file as float values
    in C
    Anyhow, the float value for a Hex value will never change, it can either be read in a big-endian or little-endian format, right?How can i get some third float value for the same Hex value?It doesnt even sound logical !!
    See more | Go to post

    Leave a comment:


  • tophandasa
    replied to Trouble reading a binary file as float values
    in C
    Help needed over here guys..Im totally convienced with the results i got, but looks like they are not the results expected by my Professor. I believe he is using other program to retrieve the data in float format. So, he said that the data i got is not the correct data. I dont know what to do now. The results im getting using my C++ program looks okay comparing with the values i get after converting the Hex values read by the TextPad Program from...
    See more | Go to post

    Leave a comment:


  • tophandasa
    replied to Trouble reading a binary file as float values
    in C
    I believe the file was created by a mac or linux OS, while im working now on a windows OS, would it make any difference?My program does produces the value 46 C3 74 BF by the float value -0.956105 but the problem, when i read these certain bytes using the program that has originally created the file im reading now, it displays the float value 1.359e+4 for the same Hex value !!
    See more | Go to post

    Leave a comment:


  • tophandasa
    replied to Trouble reading a binary file as float values
    in C
    Here is the code im working with now..

    Code:
     
    #include <iostream>
    #include <iomanip>
    #include <fstream>
    
    using namespace std;
    
    int main()
    {
        ifstream infile;
        char *inname = "o1_o2.pwr1";
    
    	const int ByteNumber=8346836; 
    	int count=0;
        unsigned i;
        int length;
    	float x;
    ...
    See more | Go to post

    Leave a comment:


  • tophandasa
    replied to Trouble reading a binary file as float values
    in C
    So, the question is "How should i tell the system to read the data as float?" knowing that the read function does not deal with float type !!
    See more | Go to post

    Leave a comment:


  • tophandasa
    replied to Trouble reading a binary file as float values
    in C
    Well, its quite hard to understand, but there should be some conversion functions that i can use here, right? or i'll have to write a function to do this conversion?Plus , what would i have to convert?the Hex values or the strange signs and letters?
    See more | Go to post

    Leave a comment:


  • tophandasa
    replied to Trouble reading a binary file as float values
    in C
    I forget to mention this..
    56E00: 44 3B 92 83 44 5A 6E EA 44 78 82 CF 44 32 E2 B7 "some strange letters and signs here"
    See more | Go to post

    Leave a comment:


  • tophandasa
    replied to Trouble reading a binary file as float values
    in C
    Interesting..
    I got numbers like this..

    56E00: 44 3B 92 83 44 5A 6E EA 44 78 82 CF 44 32 E2 B7

    what should i do now? Should i read the data in Hex mode?what should i change in my code?
    See more | Go to post

    Leave a comment:


  • tophandasa
    replied to Trouble reading a binary file as float values
    in C
    but the thing is, the output of the print statement is

    قEذج╧F¶d╟F♂EفYز EءQ3FcJmEاgdE┘≈ G>ىF17hEَ²7F X╨ F☻èؤF]P{E~h█F♦♣ŽEَ╩حF ∟&#8616F>@┬F>\¶ Ex╤
    (Eë╢صF♦µ╟E╪YٌFp فF░ç╫E═z Eùد╫F àMF►ه
    F►QDF†@═FCsإEdà ·E┘╕§F#♫F.k║F♠ IEuHùE\╜▀F☻↓7Eغ 8pEٍO RFْ♣6Fb↨╜E╕╕_F* Z+FjŽإE┐▲'F(eيE
    ■/EWT}Eآ~XEèْ♥F=→ يEأ♫SEµإ5E «/qF <╔F@ُ:F!<←F#9╔E ى┘╖ENµٍE╫Z╙E┼خ╒ F☻P>EسZ#E╥آ[EdءْE

    What do u think is the problem?
    See more | Go to post

    Leave a comment:


  • tophandasa
    replied to Trouble reading a binary file as float values
    in C
    so, how can this be done?what is wrong with my code?
    See more | Go to post

    Leave a comment:


  • tophandasa
    replied to Trouble reading a binary file as float values
    in C
    Now, my code looks like this:

    Code:
    // read a file into memory
    #include <iostream>
    #include <fstream>
    using namespace std;
    
    int main () {
      int length;
      float * buffer;
    
      //open the file
      ifstream is;
      is.open ("o1_o2.pwr1", ios::binary );
      cout << "The file is opened.." << endl;
    
      //
    ...
    See more | Go to post

    Leave a comment:


  • tophandasa
    replied to Trouble reading a binary file as float values
    in C
    the thing is, i need to output the data to the screen, but the data that comes out using these statements are "==" which has no meaning!! I modified my code to be like this:

    Code:
    ..
    
    // read a file into memory
    #include <iostream>
    #include <fstream>
    using namespace std;
    
    int main () {
      int length;
      char * buffer;
    
      //open the file
    ...
    See more | Go to post

    Leave a comment:


  • tophandasa
    replied to Trouble reading a binary file as float values
    in C
    What do u mean by "cast the address to a (char *)" ?
    How can i do this?
    See more | Go to post

    Leave a comment:


  • tophandasa
    replied to Trouble reading a binary file as float values
    in C
    Thank you for your reply, but the problem is, the read function deals with char type, i need to read the data and tprint them into the screen as a float type :(
    See more | Go to post

    Leave a comment:


  • tophandasa
    started a topic Trouble reading a binary file as float values
    in C

    Trouble reading a binary file as float values

    Hi all,
    I'm having a trouble reading a binary file as float values.I have to read the data in binary mode, then read every four bytes into a float variable. I have done my search, but i found out that the read and get functions do not accept float type. What should i do now? Can anybody help me please?

    Here is the code..
    Code:
    #include <fstream>
    
    #include <iostream>
    
    using
    ...
    See more | Go to post
    Last edited by horace1; Mar 22 '07, 09:55 PM. Reason: added code tags
No activity results to display
Show More
Working...