import utilities.FormatierteAusgabe;

/**

In diesem Programm wird eine double-Zahl in die verschiedenen anderen
primitiven Datentypen gewandelt. Zur Kontrolle der (vielleicht etwas
seltsamen) ganzzahligen Ergebnisse wird zuvor das Bitmuster der
entsprechenden long-Zahl (64-Bit) ausgegeben.<BR>
Die negativen Zahlen erhält man dadurch, daß man von der long-Zahl nur
die rechten relevanten Bits betrachtet, bei denen das Vorzeichenbit
zufällig 1 ist.

Das Programm liefert folgende Ausgabe:

64-Bit binaer : 0000 0000 0000 0000 0000 0000 0000 0000
                0000 0111 1011 1111 1010 0100 1000 0000
double : 1.3E8
float  : 1.3E8
long   : 130000000
int    : 130000000
short  : -23424
byte   : -128
char   : ?

*/
/*-----------------------------------------------------------------------*/

public class Casting
{  public static void main(String[] argv)
   {  double langeZahl = 1.3e8;
      int i;
      System.out.print("64-Bit binaer : "); System.out.flush();
      FormatierteAusgabe.binaerAusgabe((long)langeZahl, 64);
      System.out.println();
      System.out.println("double : " + langeZahl);
      System.out.println("float  : " + (float)langeZahl);
      System.out.println("long   : " + (long)langeZahl);
      System.out.println("int    : " + (int)langeZahl);
      System.out.println("short  : " + (short)langeZahl);
      System.out.println("byte   : " + (byte)langeZahl);
      System.out.println("char   : " + (char)langeZahl);
   }
}

