CLHEP VERSION Reference Documentation
CLHEP Home Page
CLHEP Documentation
CLHEP Bug Reports
RandomObjects
CLHEP
Random
RandomObjects/CLHEP/Random/DoubConv.hh
Go to the documentation of this file.
1
#ifndef DOUBCONV_HH
2
#define DOUBCONV_HH
3
4
#include <string>
5
#include <vector>
6
#include <exception>
7
8
namespace
CLHEP
{
9
10
class
DoubConvException :
public
std::exception {
11
public
:
12
DoubConvException
(
const
std::string & w)
throw
() : msg(w) {}
13
~DoubConvException
() throw() {}
14
const
char
*
what
()
const
throw() {
return
msg.c_str(); }
15
private
:
16
std::string msg;
17
};
18
19
class
DoubConv {
20
public
:
21
22
// dto2longs(d) returns (in a vector) two unsigned longs string containing the
23
// representation of its double input. This is byte-ordering
24
// independant, and depends for complete portability ONLY on adherance
25
// to the IEEE 754 standard for 64-bit floating point representation.
26
// The first unsigned long contains the high-order bits in IEEE; thus
27
// 1.0 will always be 0x3FF00000, 00000000
28
static
std::vector<unsigned long>
dto2longs
(
double
d);
29
30
// longs2double (v) returns a double containing the value represented by its
31
// input, which must be a vector containing 2 unsigned longs.
32
// The input is taken to be the representation according to
33
// the IEEE 754 standard for a 64-bit floating point number, whose value
34
// is returned as a double. The byte-ordering of the double result is,
35
// of course, tailored to the proper byte-ordering for the system.
36
static
double
longs2double
(
const
std::vector<unsigned long> &
v
);
37
38
// dtox(d) returns a 16-character string containing the (zero-filled) hex
39
// representation of its double input. This is byte-ordering
40
// independant, and depends for complete portability ONLY on adherance
41
// to the IEEE 754 standard for 64-bit floating point representation.
42
static
std::string
d2x
(
double
d);
43
44
private
:
45
union
DB8 {
46
unsigned
char
b
[8];
47
double
d;
48
};
49
static
void
fill_byte_order ();
50
static
bool
byte_order_known;
51
static
int
byte_order[8];
52
// Meaning of byte_order: The first (high-order in IEEE 754) byte to
53
// output (or the high-order byte of the first unsigned long)
54
// is of db.b[byte_order[0]]. Thus the index INTO byte_order
55
// is a position in the IEEE representation of the double, and the value
56
// of byte_order[k] is an offset in the memory representation of the
57
// double.
58
};
59
60
61
}
62
63
#endif // DOUBCONV_HH
CLHEP::DoubConvException::what
const char * what() const
Definition:
RandomObjects/CLHEP/Random/DoubConv.hh:14
b
@ b
Definition:
testCategories.cc:125
CLHEP::DoubConv::longs2double
static double longs2double(const std::vector< unsigned long > &v)
Definition:
DoubConv.cc:106
CLHEP::DoubConvException::DoubConvException
DoubConvException(const std::string &w)
Definition:
RandomObjects/CLHEP/Random/DoubConv.hh:12
CLHEP
Definition:
ClhepVersion.h:13
v
they are gone ZOOM Features Discontinued The following features of the ZOOM package were felt to be extreme overkill These have been after checking that no existing user code was utilizing as in SpaceVector v
Definition:
keyMergeIssues.doc:324
CLHEP::DoubConvException::~DoubConvException
~DoubConvException()
Definition:
RandomObjects/CLHEP/Random/DoubConv.hh:13
CLHEP::DoubConv::d2x
static std::string d2x(double d)
Definition:
DoubConv.cc:78
CLHEP::DoubConv::dto2longs
static std::vector< unsigned long > dto2longs(double d)
Definition:
DoubConv.cc:90
Generated by
1.8.17