PandocAnsiFilter/Example1.ipynb
2022-09-26 20:54:19 +02:00

185 lines
16 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"id": "13bf7a6e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"BenchmarkTools.Trial: 10000 samples with 10 evaluations.\n",
" Range \u001b[90m(\u001b[39m\u001b[36m\u001b[1mmin\u001b[22m\u001b[39m … \u001b[35mmax\u001b[39m\u001b[90m): \u001b[39m\u001b[36m\u001b[1m1.182 μs\u001b[22m\u001b[39m … \u001b[35m145.397 μs\u001b[39m \u001b[90m┊\u001b[39m GC \u001b[90m(\u001b[39mmin … max\u001b[90m): \u001b[39m0.00% … 96.62%\n",
" Time \u001b[90m(\u001b[39m\u001b[34m\u001b[1mmedian\u001b[22m\u001b[39m\u001b[90m): \u001b[39m\u001b[34m\u001b[1m1.277 μs \u001b[22m\u001b[39m\u001b[90m┊\u001b[39m GC \u001b[90m(\u001b[39mmedian\u001b[90m): \u001b[39m0.00%\n",
" Time \u001b[90m(\u001b[39m\u001b[32m\u001b[1mmean\u001b[22m\u001b[39m ± \u001b[32mσ\u001b[39m\u001b[90m): \u001b[39m\u001b[32m\u001b[1m1.789 μs\u001b[22m\u001b[39m ± \u001b[32m 4.410 μs\u001b[39m \u001b[90m┊\u001b[39m GC \u001b[90m(\u001b[39mmean ± σ\u001b[90m): \u001b[39m9.23% ± 3.75%\n",
"\n",
" \u001b[39m▄\u001b[39m█\u001b[34m█\u001b[39m\u001b[39m▅\u001b[39m▃\u001b[39m▃\u001b[39m▄\u001b[39m▃\u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[32m \u001b[39m\u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m▁\u001b[39m▃\u001b[39m▄\u001b[39m▃\u001b[39m▃\u001b[39m▄\u001b[39m▃\u001b[39m▂\u001b[39m▂\u001b[39m▁\u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m▂\n",
" \u001b[39m█\u001b[39m█\u001b[34m█\u001b[39m\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m▇\u001b[39m▇\u001b[39m▆\u001b[39m▆\u001b[39m▆\u001b[39m▁\u001b[39m▅\u001b[32m▄\u001b[39m\u001b[39m▅\u001b[39m▄\u001b[39m▅\u001b[39m▄\u001b[39m▁\u001b[39m▃\u001b[39m▄\u001b[39m▄\u001b[39m▅\u001b[39m▁\u001b[39m▁\u001b[39m▅\u001b[39m▄\u001b[39m▃\u001b[39m▃\u001b[39m▁\u001b[39m▁\u001b[39m▃\u001b[39m▃\u001b[39m▁\u001b[39m▃\u001b[39m▁\u001b[39m▃\u001b[39m▃\u001b[39m▁\u001b[39m▁\u001b[39m▄\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m▇\u001b[39m▇\u001b[39m▇\u001b[39m▆\u001b[39m▇\u001b[39m▆\u001b[39m \u001b[39m█\n",
" 1.18 μs\u001b[90m \u001b[39m\u001b[90mHistogram: \u001b[39m\u001b[90m\u001b[1mlog(\u001b[22m\u001b[39m\u001b[90mfrequency\u001b[39m\u001b[90m\u001b[1m)\u001b[22m\u001b[39m\u001b[90m by time\u001b[39m 3.51 μs \u001b[0m\u001b[1m<\u001b[22m\n",
"\n",
" Memory estimate\u001b[90m: \u001b[39m\u001b[33m7.94 KiB\u001b[39m, allocs estimate\u001b[90m: \u001b[39m\u001b[33m1\u001b[39m."
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"using BenchmarkTools\n",
"\n",
"@benchmark sum(rand(1000))"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "b1c443f8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m10000000011\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m1011100100010000000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n"
]
}
],
"source": [
"function printbitsf64(x::Float64)\n",
" s = bitstring(x)\n",
" printstyled(s[1], color = :blue, reverse=true)\n",
" printstyled(s[2:12], color = :green, reverse=true)\n",
" printstyled(s[13:end], color=:red, bold=true, reverse=true)\n",
" print(\"\\n\")\n",
"end\n",
"\n",
"printbitsf64(27.56640625)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "8f3d880c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0100000000000000000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0010000000000000000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0001000000000000000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000100000000000000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000010000000000000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000001000000000000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000100000000000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000010000000000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000001000000000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000100000000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000010000000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000001000000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000100000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000010000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000001000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000100000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000010000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000001000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000100000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000010000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000001000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000100000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000010000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000001000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000100000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000010000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000001000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000100000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000010000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000001000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000100000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000010000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000001000000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000100000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000010000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000001000000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000000100000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000000010000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000000001000000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000000000100000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000000000010000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000000000001000000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000000000000100000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000000000000010000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000000000000001000000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000000000000000100000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000000000000000010000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000000000000000001000\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000000000000000000100\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000000000000000000010\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000000000000000000001\u001b[27m\u001b[22m\u001b[39m\n",
"\u001b[34m\u001b[7m0\u001b[27m\u001b[39m\u001b[32m\u001b[7m01111111111\u001b[27m\u001b[39m\u001b[31m\u001b[1m\u001b[7m0000000000000000000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n"
]
}
],
"source": [
"Eps=0.5\n",
"while 1 != 1 + Eps\n",
" Eps/= 2\n",
" printbitsf64(1+Eps)\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "0c1f152a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[38;5;142m\u001b[7m0\u001b[27m\u001b[39m\u001b[38;5;190m\u001b[4m10000000011\u001b[24m\u001b[39m\u001b[38;5;27m\u001b[1m\u001b[7m1011100100010000000000000000000000000000000000000000\u001b[27m\u001b[22m\u001b[39m\n"
]
}
],
"source": [
"function printbits2f64(x::Float64)\n",
" s = bitstring(x)\n",
" printstyled(s[1], color = 142, reverse=true)\n",
" printstyled(s[2:12], color = 190, reverse=false, underline=true)\n",
" printstyled(s[13:end], color= 27, bold=true, reverse=true)\n",
" print(\"\\n\")\n",
"end\n",
"\n",
"printbits2f64(27.56640625)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a2175725",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia (4 threads) 1.8.1",
"language": "julia",
"name": "julia-4-threads-1.8"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.8.1"
}
},
"nbformat": 4,
"nbformat_minor": 5
}