Primitive types and operations. Kamill Gusmanov @GusmanovKamill

Слайд 2

Fibonacci number 1, 1, 2, 3, 5, 8, 13, 21…

Fibonacci number

1, 1, 2, 3, 5, 8, 13, 21…

Слайд 3

How much Fibonacci number fit into: Byte?

How much Fibonacci number fit into:

Byte?

Слайд 4

How much Fibonacci number fit into: Byte? Short?

How much Fibonacci number fit into:

Byte?
Short?

Слайд 5

How much Fibonacci number fit into: Byte? Short? Int?

How much Fibonacci number fit into:

Byte?
Short?
Int?

Слайд 6

How much Fibonacci number fit into: Byte? Short? Int? Long?

How much Fibonacci number fit into:

Byte?
Short?
Int?
Long?

Слайд 7

Random numbers Unfortunately, this code is returning binary numbers as decimal

Random numbers

Unfortunately, this code is returning binary numbers as decimal integers,

and you cannot fix the library itself, but you can write a fix, that takes the result of the function and converts it into regular integer. Use % and >> operations to complete the task.
Слайд 8

Arrays Initialize array with Pascal triangle. Print it to the screen.

Arrays

Initialize array with Pascal triangle. Print it to the screen.

Слайд 9

String

String

Слайд 10

Advanced 1. Multiply floating point numbers by 2 without floating point

Advanced

1. Multiply floating point numbers by 2 without floating point multiplication,

but using bitwise operations and Double.longBitsToDouble(long), Double.doubleToRawLongBits(double)

long ld = Double.doubleToLongBits(d);
long sign = ld >> 63;
long exp = (ld >> 52) & 0x7FF;
long mantissa = ld & 0xFFFFFFFFFFFFFL;
System.out.println(sign);
System.out.println(exp - 1023);
System.out.println(1.0 + mantissa);

Слайд 11

Advanced 2. Numerical integration. Integrate f(x) = x^4 on the interval

Advanced

2. Numerical integration. Integrate f(x) = x^4 on the interval from

-1000 to 0. Use double.