CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
CLHEP::DoubConv Class Reference

#include <DoubConv.h>

Static Public Member Functions

static std::vector< unsigned long > dto2longs (double d)
 
static double longs2double (const std::vector< unsigned long > &v)
 
static std::string d2x (double d)
 

Detailed Description

Definition at line 28 of file DoubConv.h.

Member Function Documentation

◆ d2x()

std::string CLHEP::DoubConv::d2x ( double  d)
static

Definition at line 82 of file DoubConv.cc.

82 {
83 if ( !byte_order_known ) fill_byte_order ();
84 DB8 db;
85 db.d = d;
86 std::ostringstream ss;
87 for (int i=0; i<8; ++i) {
88 int k = byte_order[i];
89 ss << std::hex << std::setw(2) << std::setfill('0') << (int)db.b[k];
90 }
91 return ss.str();
92}

Referenced by CLHEP::RanluxEngine::flat().

◆ dto2longs()

std::vector< unsigned long > CLHEP::DoubConv::dto2longs ( double  d)
static

Definition at line 94 of file DoubConv.cc.

94 {
95 std::vector<unsigned long> v(2);
96 if ( !byte_order_known ) fill_byte_order ();
97 DB8 db;
98 db.d = d;
99 v[0] = ((static_cast<unsigned long>(db.b[byte_order[0]])) << 24)
100 | ((static_cast<unsigned long>(db.b[byte_order[1]])) << 16)
101 | ((static_cast<unsigned long>(db.b[byte_order[2]])) << 8)
102 | ((static_cast<unsigned long>(db.b[byte_order[3]])) );
103 v[1] = ((static_cast<unsigned long>(db.b[byte_order[4]])) << 24)
104 | ((static_cast<unsigned long>(db.b[byte_order[5]])) << 16)
105 | ((static_cast<unsigned long>(db.b[byte_order[6]])) << 8)
106 | ((static_cast<unsigned long>(db.b[byte_order[7]])) );
107 return v;
108}

Referenced by CLHEP::HepJamesRandom::put(), CLHEP::NonRandomEngine::put(), CLHEP::Ranlux64Engine::put(), CLHEP::RandBinomial::put(), CLHEP::RandBreitWigner::put(), CLHEP::RandChiSquare::put(), CLHEP::RandExponential::put(), CLHEP::RandExpZiggurat::put(), CLHEP::RandFlat::put(), CLHEP::RandGamma::put(), CLHEP::RandGauss::put(), CLHEP::RandGeneral::put(), CLHEP::RandPoisson::put(), CLHEP::RandPoissonQ::put(), CLHEP::RandSkewNormal::put(), CLHEP::RandStudentT::put(), CLHEP::RandGauss::saveDistState(), and CLHEP::RandGauss::saveEngineStatus().

◆ longs2double()

double CLHEP::DoubConv::longs2double ( const std::vector< unsigned long > &  v)
static

Definition at line 110 of file DoubConv.cc.

110 {
111 DB8 db;
112 unsigned char bytes[8];
113 if ( !byte_order_known ) fill_byte_order ();
114 bytes[0] = static_cast<unsigned char>((v[0] >> 24) & 0xFF);
115 bytes[1] = static_cast<unsigned char>((v[0] >> 16) & 0xFF);
116 bytes[2] = static_cast<unsigned char>((v[0] >> 8) & 0xFF);
117 bytes[3] = static_cast<unsigned char>((v[0] ) & 0xFF);
118 bytes[4] = static_cast<unsigned char>((v[1] >> 24) & 0xFF);
119 bytes[5] = static_cast<unsigned char>((v[1] >> 16) & 0xFF);
120 bytes[6] = static_cast<unsigned char>((v[1] >> 8) & 0xFF);
121 bytes[7] = static_cast<unsigned char>((v[1] ) & 0xFF);
122 for (int i=0; i<8; ++i) {
123 db.b[byte_order[i]] = bytes[i];
124 }
125 return db.d;
126}

Referenced by CLHEP::RandBinomial::get(), CLHEP::RandBreitWigner::get(), CLHEP::RandChiSquare::get(), CLHEP::RandExponential::get(), CLHEP::RandExpZiggurat::get(), CLHEP::RandFlat::get(), CLHEP::RandGamma::get(), CLHEP::RandGauss::get(), CLHEP::RandGeneral::get(), CLHEP::RandPoisson::get(), CLHEP::RandPoissonQ::get(), CLHEP::RandSkewNormal::get(), CLHEP::RandStudentT::get(), CLHEP::HepJamesRandom::getState(), CLHEP::NonRandomEngine::getState(), CLHEP::Ranlux64Engine::getState(), CLHEP::RandGauss::restoreDistState(), and CLHEP::RandGauss::restoreEngineStatus().


The documentation for this class was generated from the following files: