CM6 subformat encoding function.
The function encodes the integer value in CM6 subformat. It returns the character sequence representing the numerical value. The second differences must have already been supplied to the data stream. The value is already a second difference value.
103 " +-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
107 long expo_2[] = { 0, 32, 1024, 32768, 1048576, 33554432, 134217728 };
111 long expo_2m1_o[] = { 01, 037, 01777, 077777, 03777777, 0177777777 };
122 { nflag += 16; value = -value; }
128 if (value >= expo_2[6])
130 std::cerr <<
"ERROR (CM6::encode): " 131 <<
"sample value exceeds largest value which can be handled\n" 132 <<
"Error is triggered by absolute value being ";
133 std::cerr.setf(std::ios_base::hex,std::ios_base::basefield);
134 std::cerr <<
"0x0" << value <<
">=" <<
"0x0" << expo_2[6] << std::endl;
135 std::cerr <<
"The input value passed to the encoder is " 136 <<
"0x0" << invalue << std::endl;
137 throw Terror(
"ERROR (CM6::encode): illegal value");
141 std::frexp (
double(value), &case_expo);
143 case_expo = case_expo/5;
146 if (case_expo > 5 || case_expo < 0)
148 std::cerr <<
"ERROR (CM6::encode): exponent is " 149 << case_expo << std::endl;
150 std::cerr <<
"ERROR (CM6::encode): sample value is is " 151 << invalue << std::endl;
152 throw Terror(
"ERROR (CM6::encode): illegal exponent");
155 for ( ; case_expo > 0; case_expo--)
158 jc = value/expo_2[case_expo] + nflag + mflag;
161 value = value & expo_2m1_o[case_expo];