ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
CxxUtils
CxxUtils
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-2026 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// $Id$
14
15
16
#ifndef CXXUTILS_FLOATPACKER_H
17
#define CXXUTILS_FLOATPACKER_H
18
19
20
#include <string>
21
#include <cstdint>
22
23
24
25
namespace
CxxUtils
{
26
27
57
class
FloatPacker
58
{
59
public
:
61
typedef
std::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
:
105
int
m_nmantissa
;
106
108
double
m_scale
;
109
111
double
m_invscale
;
112
114
bool
m_is_signed
;
115
117
bool
m_round
;
118
120
int
m_npack
;
121
123
Packdest
m_npack_ones
;
124
126
Packdest
m_signmask
;
127
129
int
m_nexp
;
130
132
Packdest
m_nexp_ones
;
133
135
int
m_min_exp
;
136
138
int
m_max_exp
;
139
};
140
141
142
}
// namespace CxxUtils
143
144
145
#endif
// not CXXUTILS_FLOATPACKER_H
CxxUtils::FloatPacker::m_nmantissa
int m_nmantissa
Number of bits in the mantissa + sign bit.
Definition
FloatPacker.h:105
CxxUtils::FloatPacker::unpack
double unpack(Packdest val, std::string *err=nullptr) const
Unpack the value VAL.
Definition
FloatPacker.cxx:408
CxxUtils::FloatPacker::Packdest
std::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:273
CxxUtils::FloatPacker::m_npack_ones
Packdest m_npack_ones
Mask with that many low bits set.
Definition
FloatPacker.h:123
CxxUtils::FloatPacker::m_min_exp
int m_min_exp
Minimum exponent value.
Definition
FloatPacker.h:135
CxxUtils::FloatPacker::m_nexp
int m_nexp
Number of exponent bits.
Definition
FloatPacker.h:129
CxxUtils::FloatPacker::FloatPacker
FloatPacker(int nbits, int nmantissa, double scale=1, bool is_signed=true, bool round=false)
Constructor.
Definition
FloatPacker.cxx:215
CxxUtils::FloatPacker::m_is_signed
bool m_is_signed
Should we use a sign bit?
Definition
FloatPacker.h:114
CxxUtils::FloatPacker::m_invscale
double m_invscale
Inverse of scale.
Definition
FloatPacker.h:111
CxxUtils::FloatPacker::m_npack
int m_npack
Number of bits in mantissa (exclusive of any sign bit).
Definition
FloatPacker.h:120
CxxUtils::FloatPacker::m_max_exp
int m_max_exp
Maximum exponent value.
Definition
FloatPacker.h:138
CxxUtils::FloatPacker::m_nexp_ones
Packdest m_nexp_ones
Mask with that many low bits set.
Definition
FloatPacker.h:132
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_round
bool m_round
Should we round instead of truncating?
Definition
FloatPacker.h:117
CxxUtils::FloatPacker::m_scale
double m_scale
Scale factor for stored numbers.
Definition
FloatPacker.h:108
CxxUtils
Definition
aligned_vector.h:29
Generated on
for ATLAS Offline Software by
1.17.0