private static byte[] getFixnumBytes(RubyFixnum arg, int base, boolean sign, boolean upper) { long val = arg.getLongValue(); // limit the length of negatives if possible (also faster) if (val >= Integer.MIN_VALUE && val <= Integer.MAX_VALUE) { if (sign) { return ConvertBytes.intToByteArray((int)val,base,upper); } else { switch(base) { case 2: return ConvertBytes.intToBinaryBytes((int)val); case 8: return ConvertBytes.intToOctalBytes((int)val); case 10: default: return ConvertBytes.intToCharBytes((int)val); case 16: return ConvertBytes.intToHexBytes((int)val,upper); } } } else { if (sign) { return ConvertBytes.longToByteArray(val,base,upper); } else { switch(base) { case 2: return ConvertBytes.longToBinaryBytes(val); case 8: return ConvertBytes.longToOctalBytes(val); case 10: default: return ConvertBytes.longToCharBytes(val); case 16: return ConvertBytes.longToHexBytes(val,upper); } } } }
private static byte[] getFixnumBytes(RubyFixnum arg, int base, boolean sign, boolean upper) { long val = arg.getLongValue(); // limit the length of negatives if possible (also faster) if (val >= Integer.MIN_VALUE && val <= Integer.MAX_VALUE) { if (sign) { return ConvertBytes.intToByteArray((int)val,base,upper); } else { switch(base) { case 2: return ConvertBytes.intToBinaryBytes((int)val); case 8: return ConvertBytes.intToOctalBytes((int)val); case 10: default: return ConvertBytes.intToCharBytes((int)val); case 16: return ConvertBytes.intToHexBytes((int)val,upper); } } } else { if (sign) { return ConvertBytes.longToByteArray(val,base,upper); } else { switch(base) { case 2: return ConvertBytes.longToBinaryBytes(val); case 8: return ConvertBytes.longToOctalBytes(val); case 10: default: return ConvertBytes.longToCharBytes(val); case 16: return ConvertBytes.longToHexBytes(val,upper); } } } }
private static byte[] getFixnumBytes(RubyFixnum arg, int base, boolean sign, boolean upper) { long val = arg.getLongValue(); // limit the length of negatives if possible (also faster) if (val >= Integer.MIN_VALUE && val <= Integer.MAX_VALUE) { if (sign) { return ConvertBytes.intToByteArray((int)val,base,upper); } else { switch(base) { case 2: return ConvertBytes.intToBinaryBytes((int)val); case 8: return ConvertBytes.intToOctalBytes((int)val); case 10: default: return ConvertBytes.intToCharBytes((int)val); case 16: return ConvertBytes.intToHexBytes((int)val,upper); } } } else { if (sign) { return ConvertBytes.longToByteArray(val,base,upper); } else { switch(base) { case 2: return ConvertBytes.longToBinaryBytes(val); case 8: return ConvertBytes.longToOctalBytes(val); case 10: default: return ConvertBytes.longToCharBytes(val); case 16: return ConvertBytes.longToHexBytes(val,upper); } } } }
private static byte[] getFixnumBytes(RubyFixnum arg, int base, boolean sign, boolean upper) { long val = arg.getLongValue(); // limit the length of negatives if possible (also faster) if (val >= Integer.MIN_VALUE && val <= Integer.MAX_VALUE) { if (sign) { return ConvertBytes.intToByteArray((int)val,base,upper); } else { switch(base) { case 2: return ConvertBytes.intToBinaryBytes((int)val); case 8: return ConvertBytes.intToOctalBytes((int)val); case 10: default: return ConvertBytes.intToCharBytes((int)val); case 16: return ConvertBytes.intToHexBytes((int)val,upper); } } } else { if (sign) { return ConvertBytes.longToByteArray(val,base,upper); } else { switch(base) { case 2: return ConvertBytes.longToBinaryBytes(val); case 8: return ConvertBytes.longToOctalBytes(val); case 10: default: return ConvertBytes.longToCharBytes(val); case 16: return ConvertBytes.longToHexBytes(val,upper); } } } }