Java - 비트연산자
비트 연산자(&, |, ^, ~) : 비트 단위로 논리 연산 연산자 설명 & 이항연산자, 두 비트가 모두 1이면 1을 반환 (AND) | 이항연산자, 두 비트중 하나라도 1이면 1을 반환(OR) ^ 이항연산자, 두 비트가 서로 다를경우 1을 반환(XOR) ~ 단항연산자, 비트가 0이면 1, 1이면 0을 반환(NOT) 이항연산자, 비트를 오른쪽으로 이동(Right Shift) public class BitwiseOperators { public static void main(String[] args) { int x = 10; int y = 3; System.out.printf("x & y = %d\n", x&y); // 1010(10의 2진수) & 0011(3의 2진수) = 0010 System.out.p..
Java - 이항연산자
이항연산자 : 피연산자가 두개인 연산자 1. 산술 연산자(+, -, *, /, %) : 두 항의 사칙연산, 나머지연산 public class ArithmeticOperators { public static void main(String[] args) { int x = 5; int y = 3; System.out.printf("x + y = %d\n", x+y); System.out.printf("x - y = %d\n", x-y); System.out.printf("x * y = %d\n", x*y); System.out.printf("x / y = %d\n", x/y); // 정수 / 정수 = 정수값 System.out.printf("x %% y = %d\n", x%y); // ↑위 나누기연산의 나머지..
Java - 데이터 타입 종류
1. 정수타입(long, int, short, byte) 타입 숫자 범위 bit byte long -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 64 8 int -2,147,438,648 ~ 2,147,438,647 32 4 short -32,768 ~ 32,767 16 2 byte -128 ~ 127 8 1 public class Datatype { public static void main(String[] args) { // 정수(long, int, short, byte) long l = 64L; // -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 / 64bit / 8byte // long 타입에는..