Created
February 19, 2019 19:34
-
-
Save lakinwecker/0dceee650d72fd4501c3418b2ceb2de3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
using namespace std; | |
const int size = 65536; | |
void store(); | |
double* load(); | |
int main() { | |
store(); | |
double numbers[size]; | |
for (int i = 0; i < size; i++) { | |
numbers[i] = i * 123456.789 + 2345.4321; | |
} | |
double* test = load(); | |
for (int i = 0; i < 10; i++) { | |
if (test[i] != numbers[i]) { | |
cout << i << endl; | |
cout << test[i] << endl; | |
cout << numbers[i] << endl; | |
} | |
} | |
return 0; | |
} | |
void store() { | |
ofstream file; | |
file.open("doubles.ff", ios::out | ios::binary); | |
double numbers[size]; | |
for (int i = 0; i < size; i++) { | |
numbers[i] = i * 123456.789 + 2345.4321; | |
} | |
file.write(reinterpret_cast<char *>(numbers), sizeof(double) * size); | |
file.close(); | |
} | |
double* load() { | |
ifstream file; | |
file.open("doubles.ff", ios::in | ios::binary); | |
double *numbers = new double[size]; | |
file.read(reinterpret_cast<char *>(numbers), sizeof(double) * size); | |
return numbers; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment