/usr/include/root/Math/GenVector/BitReproducible.h is in libroot-math-genvector-dev 5.34.30-0ubuntu8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | // @(#)root/mathcore:$Id$
// Authors: W. Brown, M. Fischler, L. Moneta 2005
/**********************************************************************
* *
* Copyright (c) 2005 , LCG / FNAL ROOT MathLib Team *
* *
* *
**********************************************************************/
// Header file for class LorentzVector
//
// Created by: fischler at Mon Jun 25 2005
//
// Last update: $Id$
//
#ifndef ROOT_Math_GenVector_BitReproducible
#define ROOT_Math_GenVector_BitReproducible 1
#if defined(__alpha)
#ifndef __USE_STD_IOSTREAM
#define __USE_STD_IOSTREAM
#endif
#endif
#include <iostream>
#include <string>
#include <exception>
#include <iomanip>
namespace ROOT {
namespace Math {
namespace GenVector_detail {
class BitReproducibleException : public std::exception
{
public:
BitReproducibleException(const std::string & w) throw() : fMsg(w) {}
~BitReproducibleException() throw() {}
const char* what() const throw() { return fMsg.c_str(); }
private:
std::string fMsg;
}; // DoubConvException
class BitReproducible {
public:
// dto2longs(d, i1, i2) returns (in i1 and i2) two unsigned ints
// representation of its double input. This is byte-ordering
// independent, and depends for complete portability ONLY on adherance
// to the IEEE 754 standard for 64-bit floating point representation.
// The first unsigned int contains the high-order bits in IEEE; thus
// 1.0 will always be 0x3FF00000, 00000000
static void Dto2longs(double d, unsigned int & i1, unsigned int & i2);
// longs2double (i1,i2) returns a double containing the value represented by
// its input, which must be a 2 unsigned ints.
// The input is taken to be the representation according to
// the IEEE 754 standard for a 64-bit floating point number, whose value
// is returned as a double. The byte-ordering of the double result is,
// of course, tailored to the proper byte-ordering for the system.
static double Longs2double (unsigned int i1, unsigned int i2);
// dtox(d) returns a 16-character string containing the (zero-filled) hex
// representation of its double input. This is byte-ordering
// independent, and depends for complete portability ONLY on adherance
// to the IEEE 754 standard for 64-bit floating point representation.
static std::string D2x(double d);
static void Output ( std::ostream & os, double d ) {
unsigned int i1, i2;
Dto2longs(d, i1, i2);
os << " " << i1 << " " << i2;
}
static void Input ( std::istream & is, double & d ) {
unsigned int i1, i2;
is >> i1 >> i2;
d = Longs2double(i1, i2);
}
static void Output ( std::ostream & os, float f ) {
unsigned int i1, i2;
Dto2longs( double(f), i1, i2 );
os << " " << i1 << " " << i2;
}
static void Input ( std::istream & is, float & f ) {
unsigned int i1, i2;
is >> i1 >> i2;
f = float( Longs2double(i1, i2) );
}
private:
union DB8 {
unsigned char fB[8];
double fD;
};
static void Fill_byte_order ();
static bool fgByte_order_known;
static int fgByte_order[8];
// Meaning of byte_order: The first (high-order in IEEE 754) byte to
// output (or the high-order byte of the first unsigned int)
// is of db.b[byte_order[0]]. Thus the index INTO byte_order
// is a position in the IEEE representation of the double, and the value
// of byte_order[k] is an offset in the memory representation of the
// double.
}; // BitReproducible
} // namespace _GenVector_detail
} // namespace Math
} // namespace ROOT
// A note about floats and long doubles:
//
// BitReproducible can be used with floats by doing the equivalent of
// float x = x0; BitReproducible::dto2longs (x, i, j);
// float y = BitReproducible::longs2double (i, j);
// The results are correct.
// The only inefficiency is that two integers are used where one would suffice.
//
// The same artifice will compile for long double. However, any value of the
// long double which is not precisely representable as a double will not
// give exact results for the read-back.
//
// We intend in the near future to create a templated version of this class
// which cures both the above flaws. (In the case of long double, this is
// contingent upon finding some IEEE standard for the bits in a 128-bit double.)
#endif // DOUBCONV_HH
|