ATLAS Offline Software
FloatPacker.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // $Id$
16 #ifndef CXXUTILS_FLOATPACKER_H
17 #define CXXUTILS_FLOATPACKER_H
18 
19 
20 #include <string>
21 #include <stdint.h>
22 
23 
24 
25 namespace CxxUtils {
26 
27 
58 {
59 public:
61  typedef uint32_t Packdest;
62 
63 
74  FloatPacker (int nbits,
75  int nmantissa,
76  double scale = 1,
77  bool is_signed = true,
78  bool round = false);
79 
80 
90  Packdest pack (double src, std::string* err = nullptr) const;
91 
92 
100  double unpack (Packdest val, std::string* err = nullptr) const;
101 
102 
103 private:
106 
108  double m_scale;
109 
111  double m_invscale;
112 
115 
117  bool m_round;
118 
120  int m_npack;
121 
124 
127 
129  int m_nexp;
130 
133 
136 
139 };
140 
141 
142 } // namespace CxxUtils
143 
144 
145 #endif // not CXXUTILS_FLOATPACKER_H
CxxUtils::FloatPacker::FloatPacker
FloatPacker(int nbits, int nmantissa, double scale=1, bool is_signed=true, bool round=false)
Constructor.
Definition: FloatPacker.cxx:213
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
WriteCellNoiseToCool.src
src
Definition: WriteCellNoiseToCool.py:513
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
CxxUtils::FloatPacker::m_is_signed
bool m_is_signed
Should we use a sign bit?
Definition: FloatPacker.h:114
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
CxxUtils::FloatPacker::m_npack_ones
Packdest m_npack_ones
Mask with that many low bits set.
Definition: FloatPacker.h:123
CxxUtils::FloatPacker::m_signmask
Packdest m_signmask
Mask containing the sign bit (or 0 if there's no sign bit).
Definition: FloatPacker.h:126
CxxUtils::FloatPacker::m_min_exp
int m_min_exp
Minimum exponent value.
Definition: FloatPacker.h:135
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:182
CxxUtils::FloatPacker::m_nexp
int m_nexp
Number of exponent bits.
Definition: FloatPacker.h:129
CxxUtils
Definition: aligned_vector.h:29
CxxUtils::FloatPacker::m_round
bool m_round
Should we round instead of truncating?
Definition: FloatPacker.h:117
CxxUtils::FloatPacker::Packdest
uint32_t Packdest
Type into which we pack.
Definition: FloatPacker.h:61
CxxUtils::FloatPacker::pack
Packdest pack(double src, std::string *err=nullptr) const
Pack a value.
Definition: FloatPacker.cxx:271
CxxUtils::FloatPacker::m_max_exp
int m_max_exp
Maximum exponent value.
Definition: FloatPacker.h:138
CxxUtils::FloatPacker::m_nmantissa
int m_nmantissa
Number of bits in the mantissa + sign bit.
Definition: FloatPacker.h:105
CxxUtils::FloatPacker::m_nexp_ones
Packdest m_nexp_ones
Mask with that many low bits set.
Definition: FloatPacker.h:132
CxxUtils::FloatPacker::unpack
double unpack(Packdest val, std::string *err=nullptr) const
Unpack the value VAL.
Definition: FloatPacker.cxx:405
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
CxxUtils::FloatPacker::m_invscale
double m_invscale
Inverse of scale.
Definition: FloatPacker.h:111
CxxUtils::FloatPacker
Pack/unpack floating-point data from/to a given number of bits.
Definition: FloatPacker.h:58
CxxUtils::FloatPacker::m_npack
int m_npack
Number of bits in mantissa (exclusive of any sign bit).
Definition: FloatPacker.h:120
CxxUtils::FloatPacker::m_scale
double m_scale
Scale factor for stored numbers.
Definition: FloatPacker.h:108