|
@@ -98,28 +98,58 @@ std::istream& operator>>(std::istream& is, Fp2e& input)
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& os, const Fpe& output)
|
|
std::ostream& operator<<(std::ostream& os, const Fpe& output)
|
|
{
|
|
{
|
|
- for (int i = 0; i < 12; i++)
|
|
|
|
- hex_double(os, output.data->v[i]);
|
|
|
|
|
|
+ if (os.flags() | std::ios::hex)
|
|
|
|
+ {
|
|
|
|
+ for (int i = 0; i < 12; i++)
|
|
|
|
+ hex_double(os, output.data->v[i]);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ for (int i = 0; i < 12; i++)
|
|
|
|
+ raw_double(os, output.data->v[i]);
|
|
|
|
+ }
|
|
|
|
|
|
return os;
|
|
return os;
|
|
}
|
|
}
|
|
|
|
|
|
std::istream& operator>>(std::istream& is, Fpe& input)
|
|
std::istream& operator>>(std::istream& is, Fpe& input)
|
|
-{
|
|
|
|
- for (int i = 0; i < 12; i++)
|
|
|
|
- hex_double(is, input.data->v[i]);
|
|
|
|
-
|
|
|
|
|
|
+{
|
|
|
|
+ if (is.flags() | std::ios::hex)
|
|
|
|
+ {
|
|
|
|
+ for (int i = 0; i < 12; i++)
|
|
|
|
+ hex_double(is, input.data->v[i]);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ for (int i = 0; i < 12; i++)
|
|
|
|
+ raw_double(is, input.data->v[i]);
|
|
|
|
+ }
|
|
|
|
+
|
|
return is;
|
|
return is;
|
|
}
|
|
}
|
|
|
|
|
|
std::ostream& hex_double(std::ostream& os, double d)
|
|
std::ostream& hex_double(std::ostream& os, double d)
|
|
{
|
|
{
|
|
- os.write(reinterpret_cast<const char*>(&d), sizeof(d));
|
|
|
|
|
|
+ os << *reinterpret_cast<const unsigned long long*>(&d);
|
|
|
|
|
|
return os;
|
|
return os;
|
|
}
|
|
}
|
|
|
|
|
|
std::istream& hex_double(std::istream& is, double& d)
|
|
std::istream& hex_double(std::istream& is, double& d)
|
|
|
|
+{
|
|
|
|
+ is >> *reinterpret_cast<unsigned long long*>(&d);
|
|
|
|
+
|
|
|
|
+ return is;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+std::ostream& raw_double(std::ostream& os, double d)
|
|
|
|
+{
|
|
|
|
+ os.write(reinterpret_cast<const char*>(&d), sizeof(d));
|
|
|
|
+
|
|
|
|
+ return os;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+std::istream& raw_double(std::istream& is, double& d)
|
|
{
|
|
{
|
|
is.read(reinterpret_cast<char*>(&d), sizeof(d));
|
|
is.read(reinterpret_cast<char*>(&d), sizeof(d));
|
|
|
|
|