BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
ComPackSignedExpFloat.cxx
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: ComPackSignedExpFloat.cxx,v 1.2 2009/12/23 02:59:56 zhangy Exp $
4//
5// Description:
6// class ComPackExpFloat
7//
8// Environment:
9// Software developed for the BaBar Detector at the SLAC B-Factory.
10//
11// Author List:
12// Dave Brown 10/12/00
13//
14// Copyright Information:
15// Copyright (C) 2000 LBNL
16//
17// History:
18// Migration for BESIII MDC
19//
20//
21//--------------------------------------------------------------------------
22
23//#include "BaBar/BaBar.hh"
24#include "MdcRecoUtil/ComPackSignedExpFloat.h"
25#include <assert.h>
26#include <math.h>
27using std::endl;
28using std::ostream;
29
31 unsigned maxexponent,
32 double maxval,
33 bool invert,
34 bool center) :
35 ComPackBase<double>(-maxval,maxval,nbits),
36 _packer(nbits-1,maxexponent,invert?maxval:0.0,
37 invert?0.0:maxval, center),
38 _signbit(1<<nbits-1),_signmask(~(1<<nbits-1))
39{
40 assert(maxval>0.0);
41}
42
44{;}
45
47ComPackSignedExpFloat::pack (const double value, d_ULong & packdata) const {
48// first, pack the absolute value
50 _packer.pack(fabs(value),packdata);
51 if(retval != TAG_BAD){
52 if(value>0)
53 packdata &= _signmask;
54 else
55 packdata |= _signbit;
56 }
57 return retval;
58}
59
61ComPackSignedExpFloat::unpack (const d_ULong packdata, double & value) const {
63 _packer.unpack(packdata,value);
64 if (value < 0)
65 value = 0;
66 else if(packdata&_signbit)
67 value *= -1.0;
68 return retval;
69}
70
71void
72ComPackSignedExpFloat::print(ostream& os) const {
73 os << "Signed exponential packer using exponential packer as follows:"<<endl;
74 _packer.print(os);
75}
76
77
78
79
80
81
virtual StatusCode unpack(const d_ULong, double &) const
virtual StatusCode pack(const double, d_ULong &) const
void print(std::ostream &os) const
virtual StatusCode unpack(const d_ULong, double &) const
ComPackSignedExpFloat(unsigned nbits, unsigned maxexponent, double maxval, bool invert=false, bool center=false)
void print(std::ostream &s=std::cout) const
virtual StatusCode pack(const double, d_ULong &) const