Read a decimal according to the Export encoding specification.

@param fds
Fastdeserializer containing Export stream data
@return decoded BigDecimal value
@throws IOException
328951
static public void encodeDecimal(final FastSerializer fs, BigDecimal value)
    throws IOException {
        fs.write((byte)VoltDecimalHelper.kDefaultScale);
        fs.write((byte)16);
        fs.write(VoltDecimalHelper.serializeBigDecimal(value));
    }
108505
public static double decodeDoubleDesc(byte[] src, int srcOffset)
        throws CorruptEncodingException
    {
        long bits = DataDecoder.decodeDoubleBits(src, srcOffset);
        if (bits >= 0) {
            bits ^= 0x7fffffffffffffffL;
        }
        return Double.longBitsToDouble(bits);
    }
41654
public static Byte decodeByteObjDesc(byte[] src, int srcOffset)
        throws CorruptEncodingException
    {
        try {
            int b = src[srcOffset];
            if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) {
                return null;
            }
            return decodeByteDesc(src, srcOffset + 1);
        } catch (IndexOutOfBoundsException e) {
            throw new CorruptEncodingException(null, e);
        }
    }
800144
public final int decodeUnsignedInteger() throws IOException {
		// 0XXXXXXX ... 1XXXXXXX 1XXXXXXX
		int result = decode();

		// < 128: just one byte, optimal case
		// ELSE: multiple bytes...

		if (result >= 128) {
			result = (result & 127);
			int mShift = 7;
			int b;

			do {
				// 1. Read the next octet
				b = decode();
				// 2. Multiply the value of the unsigned number represented by
				// the 7 least significant
				// bits of the octet by the current multiplier and add the
				// result to the current value.
				result += (b & 127) << mShift;
				// 3. Multiply the multiplier by 128
				mShift += 7;
				// 4. If the most significant bit of the octet was 1, go back to
				// step 1
			} while (b >= 128);
		}

		return result;
	}
645431
public void decode(AsnInputStream ais) throws AsnException {
		
		this.oid = false;
		this.integer = false;
		this.objDescriptor = false;
		this.oidValue = null;
		this.indirectReference = 0;
		this.objDescriptorValue = null;
		this.asn = false;
		this.octet = false;
		this.arbitrary = false;
		this.data = null;
		this.bitDataString = null;
		
		try {

			// The definition of EXTERNAL is
			//			
			// EXTERNAL ::= [UNIVERSAL 8] IMPLICIT SEQUENCE {
			// direct-reference OBJECT IDENTIFIER OPTIONAL,
			// indirect-reference INTEGER OPTIONAL,
			// data-value-descriptor ObjectDescriptor OPTIONAL,
			// encoding CHOICE {
			// single-ASN1-type [0] ANY,
			// octet-aligned [1] IMPLICIT OCTET STRING,
			// arbitrary [2] IMPLICIT BIT STRING }}
			//
			//			

			AsnInputStream localAsnIS = ais.readSequenceStream();
			
			while( true ) {
				if (localAsnIS.available() == 0)
					break;
				
				int tag = localAsnIS.readTag();
				if (localAsnIS.getTagClass() == Tag.CLASS_UNIVERSAL) {
					switch(tag) {
					case Tag.INTEGER:
						this.indirectReference = localAsnIS.readInteger();
						this.setInteger(true);
						break;
						
					case Tag.OBJECT_IDENTIFIER:
						this.oidValue = localAsnIS.readObjectIdentifier();
						this.setOid(true);
						break;
						
					case Tag.OBJECT_DESCRIPTOR:
						this.objDescriptorValue = localAsnIS.readGraphicString();
						this.setObjDescriptor(true);
						break;
						
					default:
						throw new AsnException("Error while decoding External: Unrecognized tag value=" + tag + ", tagClass=" + localAsnIS.getTagClass());
					}
				} else if (localAsnIS.getTagClass() == Tag.CLASS_CONTEXT_SPECIFIC) {
					
					switch(tag) {
					case External._TAG_ASN:
						this.data = localAsnIS.readSequence();
						this.setAsn(true);
						break;
						
					case External._TAG_OCTET_ALIGNED:
						this.setEncodeType(localAsnIS.readOctetString());
						setOctet(true);
						break;
						
					case External._TAG_ARBITRARY:
						this.setEncodeBitStringType(localAsnIS.readBitString());
						setArbitrary(true);
						break;
						
					default:
						throw new AsnException("Error while decoding External: Unrecognized tag value=" + tag + ", tagClass=" + localAsnIS.getTagClass());
					}

					// check: this field  must be the last
					if (localAsnIS.available() != 0)
						throw new AsnException("Error while decoding External: data field must be the last");

				} else {
					throw new AsnException("Error while decoding External: Unrecognized tag value=" + tag + ", tagClass=" + localAsnIS.getTagClass());
				}
			}
		} catch (IOException e) {
			throw new AsnException("IOException while decoding External: " + e.getMessage(), e);
		}
	}
673373
public synchronized static void read(int fd, ByteBuffer buffer) throws IOException{
        byte[] data = read(fd);
        buffer.put(data);
    }
149648
private BigDecimal convertValue(final Object value) {
		if (value == null) {
			return null;
		} else if (value instanceof BigDecimal) {
			return (BigDecimal) value;
		}

		// Try and convert "String" value
		String dataString = value.toString();
		if (Util.empty(dataString)) {
			return null;
		}

		try {
			return new BigDecimal(dataString);
		} catch (NumberFormatException ex) {
			throw new SystemException(
					"Could not convert data of type " + value.getClass() + " with String value "
					+ dataString + " to BigDecimal", ex);
		}
	}
1364172
def _read_fd(file_descr):
        
        try:
            line = os.read(file_descr, 1024 * 1024)
        except OSError:
            stream_desc = NonBlockingStreamReader._get_sd(file_descr)
            if stream_desc is not None:
                stream_desc.has_error = True
                if stream_desc.callback is not None:
                    stream_desc.callback()
            return 0

        if line:
            stream_desc = NonBlockingStreamReader._get_sd(file_descr)
            if stream_desc is None:
                return 0 # Process closing

            if IS_PYTHON3:
                try:
                    # @TODO: further develop for not ascii/unicode binary content
                    line = line.decode("ascii")
                except UnicodeDecodeError:
                    line = repr(line)
            stream_desc.buf += line
            # Break lines
            split = stream_desc.buf.split(os.linesep)
            for line in split[:-1]:
                stream_desc.read_queue.appendleft(strip_escape(line.strip()))
                if stream_desc.callback is not None:
                    stream_desc.callback()
            # Store the remainded, its either '' if last char was '\n'
            # or remaining buffer before line end
            stream_desc.buf = split[-1]
            return len(line)
        return 0
991570
def convert_ints_floats(self, flds):
        """"""
        for idx in self.idxs_float:
            flds[idx] = float(flds[idx])
        for idx in self.idxs_int:
            dig = flds[idx]
            #print 'idx={} ({}) {}'.format(idx, flds[idx], flds) # DVK
            flds[idx] = int(flds[idx]) if dig.isdigit() else dig
        for idx in self.idxs_strpat:
            hdr = self.hdr2idx.items()[idx][0]
            pat = self.strpat_hdrs[hdr]
            flds[idx] = pat.format(flds[idx])
759979
public PactDslJsonArray decimalType(BigDecimal number) {
      body.put(number);
      matchers.addRule(rootPath + appendArrayIndex(0), new NumberTypeMatcher(NumberTypeMatcher.NumberType.DECIMAL));
      return this;
  }
607277
@Override
	public int read() throws IOException {
		byte[] buf = new byte[1];

		int res = this.read(buf, 0, 1);

		if (res != -1) {
			return 0xFF & buf[0];
		}

		return res;
	}
632855
public double read_double() throws OtpErlangDecodeException {
        int tag;

        // parse the stream
        tag = read1skip_version();

        switch (tag) {
        case OtpExternal.newFloatTag: {
            return Double.longBitsToDouble(readBE(8));
        }
        case OtpExternal.floatTag: {
            BigDecimal val;
            int epos;
            int exp;
            final byte[] strbuf = new byte[31];
            String str;

            // get the string
            this.readN(strbuf);
            str = OtpErlangString.newString(strbuf);

            // find the exponent prefix 'e' in the string
            epos = str.indexOf('e', 0);

            if (epos < 0) {
                throw new OtpErlangDecodeException("Invalid float format: '"
                        + str + "'");
            }

            // remove the sign from the exponent, if positive
            String estr = str.substring(epos + 1).trim();

            if (estr.substring(0, 1).equals("+")) {
                estr = estr.substring(1);
            }

            // now put the mantissa and exponent together
            exp = Integer.valueOf(estr).intValue();
            val = new BigDecimal(str.substring(0, epos)).movePointRight(exp);

            return val.doubleValue();
        }
        default:
            throw new OtpErlangDecodeException(
                    "Wrong tag encountered, expected "
                            + OtpExternal.newFloatTag + ", got " + tag);
        }
    }
1025251
def read_float(self, little_endian=True):
        
        if little_endian:
            endian = "<"
        else:
            endian = ">"
        return self.unpack("%sf" % endian, 4)
50660
public byte[] getData(byte[] dst, int offset)
	{
		final int end = Math.min(data.length, dst.length - offset) & ~0x03;
		for (int i = 0; i < end; ++i)
			dst[offset + i] = (byte) data[i];
		return dst;
	}

	/* (non-Javadoc)
	 * @see tuwien.auto.calimero.dptxlator.DPTXlator#getSubTypes()
	 */
	public final Map getSubTypes()
	{
		return types;
	}

	/**
	 * @return the subtypes of the 4-byte unsigned translator type
	 * @see DPTXlator#getSubTypesStatic()
	 */
	protected static Map getSubTypesStatic()
	{
		return types;
	}

	private long fromDPT(int index)
	{
		final int i = 4 * index;
		return (long) data[i] << 24 | data[i + 1] << 16 | data[i + 2] << 8 | data[i + 3];
	}

	private String makeString(int index)
	{
		return appendUnit(Long.toString(fromDPT(index)));
	}

	protected void toDPT(String value, short[] dst, int index) throws KNXFormatException
	{
		try {
			toDPT(Long.decode(removeUnit(value)).longValue(), dst, index);
		}
		catch (final NumberFormatException e) {
			throw logThrow(LogLevel.WARN, "wrong value format " + value, null, value);
		}
	}

	private short[] toDPT(long value, short[] dst, int index) throws KNXFormatException
	{
		if (value < 0 || value > 0xFFFFFFFFL)
			throw logThrow(LogLevel.WARN, "translation error for " + value,
				"input value out of range", Long.toString(value));
		final int i = 4 * index;
		dst[i] = (short) ((value >> 24) & 0xFF);
		dst[i + 1] = (short) ((value >> 16) & 0xFF);
		dst[i + 2] = (short) ((value >> 8) & 0xFF);
		dst[i + 3] = (short) (value & 0xFF);
		return dst;
	}
}
23450
private void readObject(java.io.ObjectInputStream s)
        throws java.io.IOException, ClassNotFoundException {
        // Read in all fields
        s.defaultReadObject();
        // validate possibly bad fields
        if (intVal == null) {
            String message = "BigDecimal: null intVal in stream";
            throw new java.io.StreamCorruptedException(message);
        // [all values of scale are now allowed]
        }
        UnsafeHolder.setIntCompactVolatile(this, compactValFor(intVal));
    }
153207
public Integer getDecimalDigits() {
    switch (this.type) {
    case BOOLEAN_TYPE:
    case TINYINT_TYPE:
    case SMALLINT_TYPE:
    case INT_TYPE:
    case BIGINT_TYPE:
      return 0;
    case FLOAT_TYPE:
      return 7;
    case DOUBLE_TYPE:
      return 15;
    case DECIMAL_TYPE:
      return typeQualifiers.getScale();
    case TIMESTAMP_TYPE:
      return 9;
    default:
      return null;
    }
  }
242081
private static long readVLong(DataInput stream) throws IOException {
    byte firstByte = stream.readByte();
    int len = decodeVIntSize(firstByte);
    if (len == 1) {
      return firstByte;
    }
    long i = 0;
    for (int idx = 0; idx < len-1; idx++) {
      byte b = stream.readByte();
      i = i << 8;
      i = i | (b & 0xFF);
    }
    return (isNegativeVInt(firstByte) ? (i ^ -1L) : i);
  }