Java examples for Algorithm:Number
Use Packed Decimal from IBM AS400PackedDecimal
import java.util.Arrays; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.binary.Hex; import com.ibm.as400.access.AS400PackedDecimal; public class PackedDecimal { public static void main(final String[] args)throws DecoderException {/* w ww .j av a2 s . c om*/ final AS400PackedDecimal packedDecimal = new AS400PackedDecimal(5, 1); displayBytes(packedDecimal.toBytes(1501)); displayBytes((byte[]) new Hex().decode("1501")); } private static void displayBytes(final byte[] bytes) { System.out.println(new String(Hex.encodeHex(bytes)) + ": " + Arrays.toString(bytes)); } }