Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- public class Main {
- public static void main(String[] args) {
- System.out.println("===Первое задание===");
- int a = 8, b = 31, c = 45;
- System.out.println(a +" Бинарное значение = " + Integer.toBinaryString(a));
- System.out.println(b + " Бинарное значение = " + Integer.toBinaryString(b));
- System.out.println(c + " Бинарное значение = " + Integer.toBinaryString(c));
- int num1 = a>>2;
- int num2 = b>>2;
- int num3 = c>>2;
- System.out.println("========================");
- System.out.println("Сдвиг направо:");
- System.out.println(num1 + " Бинарное значение = " + Integer.toBinaryString(num1));
- System.out.println(num2 +" Бинарное значение = " + Integer.toBinaryString(num2));
- System.out.println(num3 +" Бинарное значение = " + Integer.toBinaryString(num3));
- int a1 = -18, b1 = -45, c1 = -51;
- System.out.println("========================");
- System.out.println(a1 +" Бинарное значение = " + Integer.toBinaryString(a));
- System.out.println(b1 +" Бинарное значение = " + Integer.toBinaryString(b));
- System.out.println(c1 +" Бинарное значение = " + Integer.toBinaryString(c));
- System.out.println("========================");
- System.out.println("Сдвиг налево:");
- int num4 = a1>>3;
- int num5 = b1>>3;
- int num6 = c1>>3;
- System.out.println( num4 +" Бинарное значение = " + Integer.toBinaryString(num4));
- System.out.println( num5 +" Бинарное значение = " + Integer.toBinaryString(num5));
- System.out.println( num6 +" Бинарное значение = " + Integer.toBinaryString(num6));
- System.out.println("==================");
- System.out.println("Четвертое задание:");
- System.out.println(-8 | 9);
- System.out.println(-11 | 22);
- System.out.println(-8 & 22);
- System.out.println(-11 & 9);
- System.out.println(-8 ^ -11);
- System.out.println(9 ^ 22);
- System.out.println("==================");
- System.out.println("Пятое задание:");
- int x = -22, y = 201;
- byte x1 = (byte) a, y1= (byte) b;
- double d = 22.98d;
- int x2 = (int) d;
- float f = 54.76f;
- int x3= (int) f;
- int r = 23123123;
- float x4 = (float) r;
- double d1 = 4.9734342d;
- int x5 = (int) Math.round(d1);
- System.out.println(x1);
- System.out.println(y1);
- System.out.println(x2);
- System.out.println(x3);
- System.out.println(x4);
- System.out.println(x5);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement