Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Printing Hexadecimal Code

public class PrintHexCode {
 
   public static void main(String[] args) {
      int i = 12345;
      System.out.println("Decimal is " + i);                        // 12345
      System.out.println("Hex is " + Integer.toHexString(i));       // 3039
      System.out.println("Binary is " + Integer.toBinaryString(i)); // 11000000111001
      System.out.println("Octal is " + Integer.toOctalString(i));   // 30071
      System.out.printf("Hex is %x
", i);    // 3039
      System.out.printf("Octal is %o
", i);  // 30071
 
      char c = 'a';
      System.out.println("Character is " + c);        // a
      System.out.printf("Character is %c
", c);      // a
      System.out.printf("Hex is %x
", (short)c);     // 61
      System.out.printf("Decimal is %d
", (short)c); // 97
 
      float f = 3.5f;
      System.out.println("Decimal is " + f);    // 3.5
      System.out.println(Float.toHexString(f)); // 0x1.cp1 (Fraction=1.c, Exponent=1)
 
      f = -0.75f;
      System.out.println("Decimal is " + f);    // -0.75
      System.out.println(Float.toHexString(f)); // -0x1.8p-1 (F=-1.8, E=-1)
 
      double d = 11.22;
      System.out.println("Decimal is " + d);     // 11.22
      System.out.println(Double.toHexString(d)); // 0x1.670a3d70a3d71p3 (F=1.670a3d70a3d71 E=3)
   }
}
Comment

PREVIOUS NEXT
Code Example
Java :: how to make a messages config minecraft plugin 
Java :: android system navigation back bar hide 
Java :: Note: flutterpluginspathproviderPathProviderPlugin.java uses unchecked or unsafe operations. 
Java :: java komplettes array ausgeben 
Java :: one space diagonally in java 
Java :: android java string animations 
Java :: how to create arraylist in java 
Java :: split by asterisk java 
Java :: Java Default Access Modifier package one 
Java :: polymorphism array with abstract class java 
Java :: format string precision double java 
Java :: java compareto jdei stackoverflow 
Java :: inheritance setter and getter in java 
Java :: another name for coffee 
Java :: regex pattern to mathc IP address 
Java :: setlist arraylist java swing example 
Java :: java loop array 
Java :: android int color = ContextCompat.getColor(getContext(), mColorResourceId); 
Java :: how to mutate value in vector in java 
Java :: What is accept() method in networking 
Java :: how to send a message to player in eclipse 
Java :: isblank vs isempty java string utils 
Java :: scanner in = new scanner(system.in) meaning in java 
Java :: how to decode a ByteArray to Bitman in adroid 
Java :: how to make a string alphabetic 
Java :: react-native maven package 404 not found 
Java :: komplettes array ausgeben java 
Java :: Java Another form of assertion statement 
Java :: We would like to make a member of a class can access in all subclasses regardless of what package the subclass is in. Which one of the following keywords would achieve this? 
Java :: site:stackoverflow.com List is abstract; cannot be instantiated public List<Integer result = new List<(); 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =