// The purpose of this code is to convert decimal floating point Numbers to hexadecimal
//
#include <iostream>
#include <assert.h>
#include <cassert>
#include <fstream>
#include <vector>
#include <sstream>
#include <string>
using namespace std;
constexpr auto FILE_SOURCE1 = "D:\\n3_in.txt";
constexpr auto FILE_SOURCE2 = "D:\\n3_out.txt";
int main()
{
fstream my_input;
fstream my_output;
char c1;
int count = 0;
my_input.open(FILE_SOURCE1, ios::in);
my_output.open(FILE_SOURCE2, ios::out);
if (my_input.fail())
{
return 0;
}
vector<float> floats;
string line;
//Read float
while (getline(my_input, line))
{
istringstream iss(line);
float val;
iss >> val;
floats.push_back(val);
}
my_input.close();
vector<int> ints;
for (int i = 0; i < floats.size(); i++)
{
int bbb;
bbb = (floats[i] / 6) * 8191;
ints.push_back(bbb);
}
for (int i = 0; i < ints.size(); i++)
{
my_output << hex << ints[i] << endl;
}
my_output.close();
return 0;
}