When I write a double to a filestream, then write an integer, the integer gets appended to the double as extra digits, and I have no idea why it happens. Could someone please explain this for me? Minimal example:

```
#include <iostream>
#include <fstream>

int main()
{
    std::fstream s("test.bin", std::fstream::binary | std::fstream::trunc | std::fstream::in | std::fstream::out);
    s << 3.14;
    int n = 36;
    s << n;
    s.seekp(0);
    double d;
    s >> d;
    printf("%f\n", d);
}

```

**What I expect to happen:**

* The program opens a file called test.bin
* It writes the value `3.14` to the file (8 bytes)
* It writes the value `36` to the file (4 bytes)
* It skips back to the beginning of the buffer
* It reads a double-type value (8 bytes)
* It prints the value (displaying `3.140000`)

**What actually happens:**
The program outputs `3.143600` - I have absolutely no idea why this happens. It makes zero sense. If I change the initial value, say from `3.14` to `18.3204`, then it outputs `18.320436`. What's happening?