User Profile
Collapse
-
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 !! -
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...Leave a comment:
-
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 !!Leave a comment:
-
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;
Leave a comment:
-
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 !!Leave a comment:
-
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?Leave a comment:
-
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"Leave a comment:
-
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?Leave a comment:
-
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 ∟↨F>@┬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?Leave a comment:
-
-
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; //
Leave a comment:
-
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
Leave a comment:
-
What do u mean by "cast the address to a (char *)" ?
How can i do this?Leave a comment:
-
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 :(Leave a comment:
-
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
No activity results to display
Show More
Leave a comment: