Edit or run this notebook
Scientific Computing TU Berlin Winter 2021/22 © Jürgen Fuhrmann
Notebook 08
1.7 ms
2.3 s
5.6 ms

Number representation

4.5 μs

Besides of the concrete names of Julia library functions everything in this chapter is valid for most modern programming languagues and computer systems.

5.1 μs

All data in computers are stored as sequences of bits. In Julia, for concrete number types, the bitstring function returns this information as a sequence of 0 and 1. The sizeof function returns the number of bytes in the binary representation.

5.6 μs

Integer numbers

4.2 μs
T_int
Int8
59 ns
i
1
54 ns
1
61 ns
"00000001"
2.0 μs

Positive integer numbers are represented by their representation in the binary system. For negative numbers n, the binary representation of their "two's complement" 2N|n| (where N is the number of available bits) is stored. Correspondingly, the sign of an integer number is stored in the first bit.

typemin and typemax return the smallest and largest numbers which can be represented in number type.

6.1 μs
11.3 μs

Unless the possible range of the representation (2N1,2N1) is exceeded, addition, multiplication and subtraction of integers are exact. If it is exceeded, operation results wrap around into the opposite sign region.

6.4 μs
10
74 ns
-119
64 ns
3//10
687 ns

Floating point numbers

2.7 μs
0.30000000000000004
64 ns

But this should be 0.3. What is happening ???

3.1 μs

Decimal representation of xR

Usually we write real numbers as decimal fractions and cut the representation off if the number of digits is too large or infinite.

Any real number xR can be expressed via the representation formula

x=±i=0diβiβe

with base βN,β2, significand (or mantissa) digits diN,0di<β and exponent eZ.

This representation is infinite for periodic decimal numbers and irrational numbers.

10.0 μs
Loading...
ii