当前位置: 首页>>代码示例>>Java>>正文


Java BigInteger.or方法代码示例

本文整理汇总了Java中java.math.BigInteger.or方法的典型用法代码示例。如果您正苦于以下问题:Java BigInteger.or方法的具体用法?Java BigInteger.or怎么用?Java BigInteger.or使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.math.BigInteger的用法示例。


在下文中一共展示了BigInteger.or方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import java.math.BigInteger; //导入方法依赖的package包/类
@Override
public void execute(EVMState state, Opcode opcode) throws EVMException {
    EVMStack stack = state.getStack();
    TraceableWord traceableWord0 = stack.pop();
    TraceableWord traceableWord1 = stack.pop();

    BigInteger element0 = new BigInteger(traceableWord0.getBytes());
    BigInteger element1 = new BigInteger(traceableWord1.getBytes());
    BigInteger result = element0.or(element1);

    TraceableWord traceableWord = new TraceableWord(result.toByteArray());
    TraceTree traceTree = buildTraceTree(opcode, traceableWord, Lists.of(traceableWord0, traceableWord1));
    traceTree.addChild(traceableWord0.getTrace());
    traceTree.addChild(traceableWord1.getTrace());
    traceableWord.setTrace(traceTree);

    stack.push(traceableWord);
}
 
开发者ID:fergarrui,项目名称:ethereum-bytecode-analyzer,代码行数:19,代码来源:Or.java

示例2: read

import java.math.BigInteger; //导入方法依赖的package包/类
private static BigInteger read(BinaryStream stream, int maxSize) {
    BigInteger result = BigInteger.ZERO;
    int offset = 0;
    int b;

    do {
        if (offset >= maxSize) {
            throw new IllegalArgumentException("VarInt too big");
        }

        b = stream.getByte();
        result = result.or(BigInteger.valueOf((b & 0x7f) << (offset * 7)));
        offset++;
    } while ((b & 0x80) > 0);

    return result;
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:18,代码来源:VarInt.java

示例3: readUnsignedBigInteger

import java.math.BigInteger; //导入方法依赖的package包/类
private static BigInteger readUnsignedBigInteger(ByteBuf buf) {
    BigInteger decodedValue = BigInteger.ZERO;
    int shiftAmount = 0;

    int in;

    do {
        in = buf.readByte();
        decodedValue = decodedValue.or(BigInteger.valueOf((in & INT_127) << shiftAmount));
        shiftAmount += SHIFT_AMOUNT;
    } while ((in & INT_128) != 0);

    return decodedValue;
}
 
开发者ID:JungleTree,项目名称:JungleTree,代码行数:15,代码来源:ByteBufUtils.java

示例4: Encode

import java.math.BigInteger; //导入方法依赖的package包/类
static String Encode(long plain, final String prefix) {

			BigInteger id = BigInteger.valueOf(plain);
			if (plain < 0) {
				id = id.add(Format.two64);
			}

			BigInteger chs = BigInteger.ZERO;
			BigInteger andVal = BigInteger.valueOf(0x3FF);
			BigInteger tmp = id;
			while (tmp.compareTo(BigInteger.ZERO) > 0) {
				chs = chs.xor(tmp.and(andVal));
				tmp = tmp.shiftRight(10);
			}
			id = id.or(chs.shiftLeft(64));
			id = id.setBit(74);

			StringBuilder idStr = new StringBuilder(prefix);
			andVal = BigInteger.valueOf(0x1F);

			for (int i = 0; i < 15; i++) {
				if ((i % 5) == 0) {
					idStr.append('-');
				}

				idStr.append(alphabet.charAt(id.and(andVal).intValue()));
				id = id.shiftRight(5);
			}

			return idStr.toString();
		}
 
开发者ID:EonTechnology,项目名称:server,代码行数:32,代码来源:Format.java

示例5: changeBase2

import java.math.BigInteger; //导入方法依赖的package包/类
private static byte[] changeBase2(byte[] src, int dstPower, int srcPower) {
	double tmpResultSize = (src.length * (double) srcPower) / dstPower;
	int resultSize = (int) Math.ceil(tmpResultSize);
	byte[] result = new byte[resultSize];

	int dstIdx = 0;

	long mask = (1 << dstPower) - 1; // 00111111

	int workingBits = 0;
	BigInteger buffer = BigInteger.valueOf(0);
	for (byte aSrc : src) {
		int unsignedIntValue = aSrc & 0xff;
		buffer = buffer.or(BigInteger.valueOf(unsignedIntValue).shiftLeft(
				workingBits));

		workingBits += srcPower;

		while (workingBits > dstPower) {
			result[dstIdx++] = buffer.and(BigInteger.valueOf(mask))
					.byteValue();
			buffer = buffer.shiftRight(dstPower);
			workingBits -= dstPower;
		}
	}

	// now, we could have a partial value left in the work buffer..
	if (workingBits > 0) {
		result[dstIdx++] = buffer.and(BigInteger.valueOf(mask)).byteValue();
	}
	return result;
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:33,代码来源:EncFSBase64.java

示例6: main

import java.math.BigInteger; //导入方法依赖的package包/类
public static void main(String[] args) {

        Scanner scann = new Scanner(System.in);
        String inputNumber = scann.nextLine();

        /*BigInteger mask = BigInteger.valueOf(7L);
        mask = mask.shiftLeft(61);*/
        BigInteger mask = new  BigInteger("e000000000000000", 16);
        BigInteger num = new BigInteger(inputNumber);

        // System.out.printf("%16s -> %s%n", "mask length", mask.toString(2).length());
        // System.out.printf("%16s -> %s%n", "binary mask",mask.toString(2));
        // System.out.printf("%16s -> %s%n", "binary num",num.toString(2));

        while (mask.compareTo(BigInteger.valueOf(7L)) >= 0){
            //System.out.printf("%16s -> %s%n", "mask & num", mask.and(num).toString(2));
            boolean treeConsecutiveOnes = Objects.equals(num.and(mask), mask);
            boolean treeConsecutiveZeroes = Objects.equals(num.and(mask), BigInteger.ZERO);
            if(treeConsecutiveOnes || treeConsecutiveZeroes){
                if(treeConsecutiveOnes){
                    //num &= (~mask)
                    num = num.andNot(mask);
                    //System.out.printf("%16s -> %s%n", "num &= (~mask)", num.toString(2));
                } else {
                    // num |= mask
                    num = num.or(mask);
                    //System.out.printf("%16s -> %s%n", "num |= mask", num.toString(2));
                }
                // move mask right
                mask = mask.shiftRight(3);
                //System.out.printf("%16s -> %s%n", "mask >> 3 ", mask.toString(2));
            } else {
                mask = mask.shiftRight(1);
                //System.out.printf("%16s -> %s%n","mask >> 1", mask.toString(2));
            }
        }
        System.out.println(num);
    }
 
开发者ID:kostovhg,项目名称:SoftUni,代码行数:39,代码来源:p01_BitFlipper.java

示例7: toBigInteger

import java.math.BigInteger; //导入方法依赖的package包/类
public static BigInteger toBigInteger(final byte[] array, final int offset, final int length) {
	BigInteger result = new BigInteger(1, new byte[] {});
	for (int i = (offset + length - 1); i >= offset; i--) {
		result = result.shiftLeft(LONG_BYTES);
		result = result.or(BigInteger.valueOf(array[i] & 0xFF));
	}
	return result;
}
 
开发者ID:arangodb,项目名称:java-velocypack,代码行数:9,代码来源:NumberUtil.java

示例8: valInt

import java.math.BigInteger; //导入方法依赖的package包/类
@Override
public BigInteger valInt() {
    if (args.get(0).isNullValue()) {
        nullValue = true; /* purecov: inspected */
        return BigInteger.ZERO; /* purecov: inspected */
    }
    if (args.get(1).isNullValue()) {
        nullValue = true;
        return BigInteger.ZERO;
    }
    nullValue = false;
    BigInteger arg1 = args.get(0).valInt();
    BigInteger arg2 = args.get(1).valInt();
    return arg1.or(arg2);
}
 
开发者ID:actiontech,项目名称:dble,代码行数:16,代码来源:ItemFuncBitOr.java

示例9: actionPerformed

import java.math.BigInteger; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
    //Get all the required data from data keys
    final Editor editor = e.getRequiredData(CommonDataKeys.EDITOR);
    final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    //Access document, caret, and selection
    final Document document = editor.getDocument();
    final SelectionModel selectionModel = editor.getSelectionModel();

    final int start = selectionModel.getSelectionStart();
    final int end = selectionModel.getSelectionEnd();
    //New instance of Runnable to make a replacement
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            //  return hex(random.randint(0, 2 ** 64) | 1 << 63)
            // from 0 to 64
            BigInteger rand = new BigInteger(64, new Random());
            rand = rand.or(new BigInteger("1").shiftLeft(63));
            String capnpId = rand.toString(16);
            document.setText( String.format("@0x%s; \n\n", capnpId) + document.getText());
        }
    };
    //Making the replacement
    WriteCommandAction.runWriteCommandAction(project, runnable);
    selectionModel.removeSelection();
}
 
开发者ID:xmonader,项目名称:sercapnp,代码行数:28,代码来源:GenerateCapnpID.java

示例10: DERObjectIdentifier

import java.math.BigInteger; //导入方法依赖的package包/类
DERObjectIdentifier(
    byte[]  bytes)
{
    StringBuffer    objId = new StringBuffer();
    long            value = 0;
    BigInteger      bigValue = null;
    boolean         first = true;

    for (int i = 0; i != bytes.length; i++)
    {
        int b = bytes[i] & 0xff;

        if (value < 0x80000000000000L) 
        {
            value = value * 128 + (b & 0x7f);
            if ((b & 0x80) == 0)             // end of number reached
            {
                if (first)
                {
                    switch ((int)value / 40)
                    {
                    case 0:
                        objId.append('0');
                        break;
                    case 1:
                        objId.append('1');
                        value -= 40;
                        break;
                    default:
                        objId.append('2');
                        value -= 80;
                    }
                    first = false;
                }

                objId.append('.');
                objId.append(value);
                value = 0;
            }
        } 
        else 
        {
            if (bigValue == null)
            {
                bigValue = BigInteger.valueOf(value);
            }
            bigValue = bigValue.shiftLeft(7);
            bigValue = bigValue.or(BigInteger.valueOf(b & 0x7f));
            if ((b & 0x80) == 0) 
            {
                objId.append('.');
                objId.append(bigValue);
                bigValue = null;
                value = 0;
            }
        }
    }

    this.identifier = objId.toString();
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:61,代码来源:DERObjectIdentifier.java

示例11: DERObjectIdentifier

import java.math.BigInteger; //导入方法依赖的package包/类
DERObjectIdentifier(
    byte[] bytes)
{
    StringBuffer objId = new StringBuffer();
    long value = 0;
    BigInteger bigValue = null;
    boolean first = true;

    for (int i = 0; i != bytes.length; i++)
    {
        int b = bytes[i] & 0xff;

        if (value <= LONG_LIMIT)
        {
            value += (b & 0x7f);
            if ((b & 0x80) == 0)             // end of number reached
            {
                if (first)
                {
                    if (value < 40)
                    {
                        objId.append('0');
                    }
                    else if (value < 80)
                    {
                        objId.append('1');
                        value -= 40;
                    }
                    else
                    {
                        objId.append('2');
                        value -= 80;
                    }
                    first = false;
                }

                objId.append('.');
                objId.append(value);
                value = 0;
            }
            else
            {
                value <<= 7;
            }
        }
        else
        {
            if (bigValue == null)
            {
                bigValue = BigInteger.valueOf(value);
            }
            bigValue = bigValue.or(BigInteger.valueOf(b & 0x7f));
            if ((b & 0x80) == 0)
            {
                if (first)
                {
                    objId.append('2');
                    bigValue = bigValue.subtract(BigInteger.valueOf(80));
                    first = false;
                }

                objId.append('.');
                objId.append(bigValue);
                bigValue = null;
                value = 0;
            }
            else
            {
                bigValue = bigValue.shiftLeft(7);
            }
        }
    }

    this.identifier = objId.toString();
    this.body = Arrays.clone(bytes);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:77,代码来源:DERObjectIdentifier.java

示例12: or

import java.math.BigInteger; //导入方法依赖的package包/类
public static BigInteger or( BigInteger a, BigInteger b ) {
   return a.or( b );
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:4,代码来源:Math.java

示例13: DERObjectIdentifier

import java.math.BigInteger; //导入方法依赖的package包/类
DERObjectIdentifier(
    byte[]  bytes)
{
    StringBuilder objId = new StringBuilder();
    long            value = 0;
    BigInteger      bigValue = null;
    boolean         first = true;

    for (int i = 0; i != bytes.length; i++)
    {
        int b = bytes[i] & 0xff;

        if (value < 0x80000000000000L)
        {
            value = value * 128 + (b & 0x7f);
            if ((b & 0x80) == 0)             // end of number reached
            {
                if (first)
                {
                    switch ((int)value / 40)
                    {
                    case 0:
                        objId.append('0');
                        break;
                    case 1:
                        objId.append('1');
                        value -= 40;
                        break;
                    default:
                        objId.append('2');
                        value -= 80;
                    }
                    first = false;
                }

                objId.append('.');
                objId.append(value);
                value = 0;
            }
        }
        else
        {
            if (bigValue == null)
            {
                bigValue = BigInteger.valueOf(value);
            }
            bigValue = bigValue.shiftLeft(7);
            bigValue = bigValue.or(BigInteger.valueOf(b & 0x7f));
            if ((b & 0x80) == 0)
            {
                objId.append('.');
                objId.append(bigValue);
                bigValue = null;
                value = 0;
            }
        }
    }

    this.identifier = objId.toString();
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:61,代码来源:DERObjectIdentifier.java


注:本文中的java.math.BigInteger.or方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。