Here you can find the source of expandToLength16(byte scaledValue[], final boolean isNegative)
Parameter | Description |
---|---|
scaledValue | Scaled twos complement representation of the decimal |
isNegative | Determines whether the sign bit is set |
private static final byte[] expandToLength16(byte scaledValue[], final boolean isNegative)
//package com.java2s; /* This file is part of VoltDB. * Copyright (C) 2008-2010 VoltDB L.L.C. * * VoltDB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version./*from www . ja v a2s . co m*/ * * VoltDB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with VoltDB. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Converts BigInteger's byte representation containing a scaled magnitude to a fixed size 16 byte array * and set the sign in the most significant byte's most significant bit. * @param scaledValue Scaled twos complement representation of the decimal * @param isNegative Determines whether the sign bit is set * @return */ private static final byte[] expandToLength16(byte scaledValue[], final boolean isNegative) { if (scaledValue.length == 16) { return scaledValue; } byte replacement[] = new byte[16]; if (isNegative) { java.util.Arrays.fill(replacement, (byte) -1); } for (int ii = 15; 15 - ii < scaledValue.length; ii--) { replacement[ii] = scaledValue[ii - (replacement.length - scaledValue.length)]; } return replacement; } }