Aristarkos/notebooks/arithmetic.jl

61 lines
1.6 KiB
Julia

### A Pluto.jl notebook ###
# v0.12.4
using Markdown
using InteractiveUtils
# ╔═╡ 572d8e50-157c-11eb-180b-71b9ec6cecd1
# floating point division
3/2
# ╔═╡ 5e228594-157c-11eb-0554-132854b9b2fd
typeof(3/2)
# ╔═╡ 65f52060-157c-11eb-0511-d5bd5e859ac3
# integer division
3 ÷ 2 == div(3,2)
# ╔═╡ b54e5e42-157c-11eb-3aba-57905396206d
234 % 13 == rem(234, 13)
# ╔═╡ 42932eb8-157d-11eb-1dc7-7f070e37d21c
# best to use rem: % has another meaning
257 % UInt8 # truncation of binary representation to fit UInt8
# ╔═╡ 7c81c31e-157d-11eb-0310-970e544301f9
UInt8(257)
# ╔═╡ 98a4b0b0-157d-11eb-2afc-c39975e0b404
# complex numbers
1+3im
# ╔═╡ a0274b40-157d-11eb-28c5-7961c9a08770
typeof(im), typeof(1e2im)
# ╔═╡ e3386d42-157d-11eb-10ed-116fe8f3606e
exp(100+pi*1im)
# ╔═╡ 21327e58-157e-11eb-072a-79dc893f465f
# exact fractionals
1//2 + 2//3
# ╔═╡ 2b65cb78-157e-11eb-258a-f333ab2e64e5
numerator(3//4), denominator(3//4)
# ╔═╡ ad1d9312-157e-11eb-31a2-49de58fffdfe
typeof(exp)
# ╔═╡ Cell order:
# ╠═572d8e50-157c-11eb-180b-71b9ec6cecd1
# ╠═5e228594-157c-11eb-0554-132854b9b2fd
# ╠═65f52060-157c-11eb-0511-d5bd5e859ac3
# ╠═b54e5e42-157c-11eb-3aba-57905396206d
# ╠═42932eb8-157d-11eb-1dc7-7f070e37d21c
# ╠═7c81c31e-157d-11eb-0310-970e544301f9
# ╠═98a4b0b0-157d-11eb-2afc-c39975e0b404
# ╠═a0274b40-157d-11eb-28c5-7961c9a08770
# ╠═e3386d42-157d-11eb-10ed-116fe8f3606e
# ╠═21327e58-157e-11eb-072a-79dc893f465f
# ╠═2b65cb78-157e-11eb-258a-f333ab2e64e5
# ╠═ad1d9312-157e-11eb-31a2-49de58fffdfe