Java tutorial
//package com.java2s; //License from project: Apache License import java.math.BigInteger; public class Main { public static int VarIntLength(long value) { if (value < 253) return 1; if (value < 65536) return 3; BigInteger bytes5 = new BigInteger("4294967296"); if (value < bytes5.longValue()) return 5; return 9; } }