Yes, I am storing double values in a binary file. (I am using Matlab for that.)
In fact, I am not sure if it is correct to say "I am storing doubles". May be it is more correct to say I am storing int values from 1 to 1000000 in a binary file.
The problem is that the code above can read from 1 to 255 only. For the next values it returns 255 to me.
You'll have to piece them together. You'll need to know the file's endianness (you can read the article on endianness on Wikipedia).
As an example, to make a 16-bit integer out of big endian bytes, you just do (byte[0]<<8)|byte[1]. Read the article and you'll understand how to do it for larger integers.
Hey helios, can you explain in more details please...I did not understant what you want to say with "...piece them together."
I am not sure that it was needed to spend attention with endianess.I have not considerated this yet and, in fact, I can read the data from the binary file. The point is that get() is only able to return a value between 0 and 255.
But I will read the article on endianness on Wikipedia.
Before you use it, though, you should definitely find out exactly how the data you are reading is stored. As already stated by helios, storing floating point values in a file in binary format is not a good idea. It is better just to store the textual representation (like "12.934e-7"), then read/write it using the iostream extraction/insertion operators (operator>> and operator<<).
A file is a collection of bytes. An integer is a smaller collection of bytes. When you're using C++, the language handles manipulating these bytes for you, but you don't have that luxury with files, so you have to do it yourself.
Oh. Look up the meaning of the shift operators (<< left and >> right) and bitwise OR (|) if you don't know them already.
I am not storing floating point values. When I had used double in matlab(to produce the binary file) it was because uint8 was not creating values higher than 255.
So they are floating point values. The fact that you were using them to store integers is irrelevant. Also, why not use uint32 or uint64 if you just needed larger integers?