fork(3) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void writeVarInt(int value) {
  11. do {
  12. byte temp = (byte)(value & 0b01111111);
  13. // Note: >>> means that the sign bit is shifted with the rest of the number rather than being left alone
  14. value >>>= 7;
  15. if (value != 0) {
  16. temp |= 0b10000000;
  17. }
  18. System.out.println(Integer.toHexString(temp & 0xff));
  19.  
  20. } while (value != 0);
  21. }
  22. public static void main (String[] args) throws java.lang.Exception
  23. {
  24. writeVarInt(-1);
  25. }
  26. }
Success #stdin #stdout 0.1s 27620KB
stdin
Standard input is empty
stdout
ff
ff
ff
ff
f