From 916a39f06683e7675fab8cd29ed4cd973201e3dd Mon Sep 17 00:00:00 2001 From: Xuan Huang Date: Sun, 21 Jun 2020 23:07:36 -0700 Subject: [PATCH] [self] --- _posts/data_rep/2020-06-19-data-rep-int.md | 54 +++--- _posts/data_rep/2020-06-21-data-rep-float.md | 192 +++++++++++++++++++ _posts/data_rep/2020-06-21-data-rep-todo.md | 22 +++ css/hux-blog.css | 5 - css/hux-blog.min.css | 5 - js/hux-blog.min.js | 5 - less/side-catalog.less | 3 +- 7 files changed, 247 insertions(+), 39 deletions(-) create mode 100644 _posts/data_rep/2020-06-21-data-rep-float.md create mode 100644 _posts/data_rep/2020-06-21-data-rep-todo.md diff --git a/_posts/data_rep/2020-06-19-data-rep-int.md b/_posts/data_rep/2020-06-19-data-rep-int.md index 27cc65cf182..7d8adc4d1aa 100644 --- a/_posts/data_rep/2020-06-19-data-rep-int.md +++ b/_posts/data_rep/2020-06-19-data-rep-int.md @@ -1,6 +1,6 @@ --- title: "Data Representation - Integer" -subtitle: "「数据表示」整型" +subtitle: "「数据表示」整数" layout: post author: "Hux" header-style: text @@ -12,10 +12,12 @@ tags: - C++ --- -Integers, or _whole number_ are _fixed-point numbers_, contrast to _floating-point numbers_. -Computers treat them very differently. +Integers, or _whole number_ from elemental mathematics, are the most common and +fundamental numbers used in the computers. It's represented as +_fixed-point numbers_, contrast to _floating-point numbers_ in the machine. +Today we are going to learn a whole bunch of way to encode it. -Two properties that distinguish an integer representation: +There are mainly two properties to make a integer representation different: 1. **Size, of the number of bits used**. usually the power of 2. e.g. 8-bit, 16-bit, 32-bit, 64-bit. @@ -23,32 +25,33 @@ usually the power of 2. e.g. 8-bit, 16-bit, 32-bit, 64-bit. 2. **Signed or unsigned**. there are also multiple schemas to encode a signed integers. -Some terminologies we will used: +We are also gonna use the below terminologies throughout the post: - _MSB_: Most Significant Bit - _LSB_: Least Significant Bit -Prerequisite - `printf` Recap (Integers) +Prerequisite - `printf` Recap ---------------------------------------- +We will quickly recap the integers subset of usages of `printf`. +Basically, we used _format specifier_ to interpolate values into strings: + ### [Format Specifier](http://www.cplusplus.com/reference/cstdio/printf/) > `%[flags][width][.precision][length]specifier` -specificier -- `d`, `i` : signed decimal -- `u` : unsigned decimal -- `c` : char -- `p`: pointer addr -- `x` / `X` : lower/upper unsigned hex - -length -- `l` : long (at least 32) -- `ll` : long long (at least 64) -- `h` : short (usually 16) -- `hh` : short short (usually 8) - +- `specifier` + - `d`, `i` : signed decimal + - `u` : unsigned decimal + - `c` : char + - `p`: pointer addr + - `x` / `X` : lower/upper unsigned hex +- `length` + - `l` : long (at least 32) + - `ll` : long long (at least 64) + - `h` : short (usually 16) + - `hh` : short short (usually 8) ```cpp using namespace std; @@ -293,11 +296,15 @@ printf("%"PRIxPTR "\n", (uintptr_t)s8); // ffffffffffffff80 ``` -Char +Char & [ASCII](https://en.wikipedia.org/wiki/ASCII) ----------------- -Traditionally, `char` is represented in the computer as 8 bits as well. It's -more complicated in nowadays Unicode era but we'll ignore that for future posts. +Traditionally, `char` is represented in the computer as 8 bits as well. And +really, ASCII is only defined between `0` and `127` and require 7 bits. +(8-bit Extended ASCII is not quite well popularized and supported.) + +It's more complicated in extension such as _Unicode_ nowadays, but we'll ignore +it for future posts dedicated for char and string representation. So how is a `char` different with a _byte_? @@ -306,6 +313,9 @@ or a `unsigned char` (backed by `uint8_t`) is... _implementaton-defined_. And most systems made it _signed_ since most types (e.g. `int`) were signed by default. +N.B. `int` is standard-defined to be equivalent to `signed int`. This is +not the case of `char`. + That's why you often see such `typedef` such as: ```cpp diff --git a/_posts/data_rep/2020-06-21-data-rep-float.md b/_posts/data_rep/2020-06-21-data-rep-float.md new file mode 100644 index 00000000000..22121e96bcc --- /dev/null +++ b/_posts/data_rep/2020-06-21-data-rep-float.md @@ -0,0 +1,192 @@ +--- +title: "Data Representation - Floating Point Numbers" +subtitle: "「数据表示」浮点数" +layout: post +author: "Hux" +header-style: text +hidden: true +tags: + - 笔记 + - 基础 + - C + - C++ +--- + +In the last episode we talked about the data representation of integer, a kind +of fixed-point numbers. Today we're going to learn about floating-point numbers. + +Floating-point numbers are used to _approximate_ real numbers. Because of the +fact that all the stuffs in computers are, eventually, just a limited sequence +of bits. The representation of floating-point number had to made trade-offs +between _ranges_ and _precision_. + +Due to its computational complexities, CPU also have a dedicated set of +instructions to accelerate on floating-point arithmetics. + + +Terminologies +------------- + +The terminologies of floating-point number is coming from the +[_scientific notation_](https://en.wikipedia.org/wiki/Scientific_notation), +where a real number can be represented as such: + +``` +1.2345 = 12345 × 10 ** -4 + ----- -- -- + significand^ ^base ^exponent +``` + +- _significand_, or _mantissa_, 有效数字, 尾数 +- _base_, or _radix_ 底数 +- _exponent_, 幂 + +So where is the _floating point_? It's the `.` of `1.2345`. Imaging the dot +can be float to the left by one to make the representation `.12345`. + +The dot is called _radix point_, because to us it's seem to be a _decimal point_, +but it's really a _binary point_ in the computers. + +Now it becomes clear that, to represent a floating-point number in computers, +we will simply assign some bits for _significand_ and some for _exponent_, and +potentially a bit for _sign_ and that's it. + + +IEEE-754 32-bits Single-Precision Floats 单精度浮点数 +---------------------------------------- + +- + +It was called **single** back to IEEE-754-1985 and now **binary32** in the +relatively new IEEE-754-2008 standard. + +```cpp + (8 bits) (23 bits) +sign exponent fraction + 0 011 1111 1 000 0000 0000 0000 0000 0000 + + 31 30 .... 23 22 ....................... 0 +``` + +- The _sign_ part took 1 bit to indicate the sign of the floats +- The _exponent_ part took 8 bits and represent a signed integer in _biased form_. +It's a variant of _excess-128_ since it took out the `-127` (all 0s) and `128` +(all 1s) for special numbers, so instead of unsigned `128`, the `u127` represent +the actual `0`, and ranges `[-126, 127]` instead of `[-127, 128]`. +- The _fraction_ part took 23 bits with an _implicit leading bit_ `1` and +represent the actual _significand_ in total precision of 24-bits. + +Don't be confused by why it's called _fraction_ instead of _significand_! +It's all because that the 23 bits in the representation is indeed, representing +the fraction part of the real significand in the scientific notation. + +The floating-point version of "scientific notation" is more like: + +```cpp +(leading 1) + 1. fraction × 2 ^ exponent × sign + (base-2) (base-2) +``` + +So what number does the above bits represent? + +```cpp +S F × E = R ++ 1.(0) × 0 = 1 +``` + +Aha! It's the real number `1`! +Recall that the `E = 0b0111 1111 = 0` because it used a biased representation! + + + +Code Sample +----------- + +Writing sample code converting between binaries (in hex) and floats are not +as straightforward as it for integers. Luckily, there are still some hacks to +perform it: + +### C - Unsafe Cast + +We unsafely cast a pointer to enable reinterpretation of the same binaries. + +```cpp +float f1 = 0x3f800000; // C doesn't have a floating literal taking hex. +printf("%f \n", f1); // 1065353216.000000 (???) + +uint32_t u2 = 0x3f800000; +float* f2 = (float*)&u2; // unsafe cast +printf("%f \n", *f2); // 1.000000 +``` + +### C - Union Trick + +Oh I really enjoyed this one...Union in C is not only untagged union, but also +share the exact same chunk of memory. So we are doing the same reinterpretation, +but in a more structural and technically fancier way. + +```cpp +#include +#include +#include + +float pi = (float)M_PI; +union { + float f; + uint32_t u; +} f2u = { .f = pi }; // we took the data as float + +printf ("pi : %f\n : 0x%" PRIx32 "\n", pi, f2u.u); // but interpret as uint32_t +pi : 3.141593 + : 0x40490fdb +``` + +N.B. this trick is well-known as [type punning](https://en.wikipedia.org/wiki/Type_punning): + +> In computer science, type punning is a common term for any programming technique that subverts or circumvents the type system of a programming language in order to achieve an effect that would be difficult or impossible to achieve within the bounds of the formal language. + +### C++ - `reinterpret_cast` + +C++ does provide such type punning to the standard language: + +```cpp +uint32_t u = 0x40490fdb; +float a = *reinterpret_cast(&u); +std::cout << a; // 3.14159 +``` + +N.B. it still need to be a conversion between pointers, +see . + +Besides, C++ 17 does add a floating point literal that can take hex, but it +works in a different way, using an explicit radix point in the hex: + +```cpp +float f = 0x1.2p3; // 1.2 by 2^3 +std::cout << f; // 9 +``` + + +IEEE-754 64-bits Double-Precision Floats +---------------------------------------- + +- + +Now, the 64-bit versions floating-point number, known as `double`, is just a +matter of scale: + +```cpp + (11 bits) (52 bits) +sign exponent fraction + 0 + + 63 62 .... 52 51 ....................... 0 +``` + + +References +---------- + +- +- \ No newline at end of file diff --git a/_posts/data_rep/2020-06-21-data-rep-todo.md b/_posts/data_rep/2020-06-21-data-rep-todo.md new file mode 100644 index 00000000000..9e6c8535d38 --- /dev/null +++ b/_posts/data_rep/2020-06-21-data-rep-todo.md @@ -0,0 +1,22 @@ +--- +title: "Data Representation - TODO" +subtitle: "「数据表示」待写" +layout: post +author: "Hux" +header-style: text +hidden: true +tags: + - 笔记 + - 基础 + - C + - C++ +--- + +- Endianness +- String (Char Sequence e.g. NULL `0x00`) +- Unicode / UTF8 +- Struct and Alignment +- Tagging + - Tagged Pointer + - NaN tagging + - Tagged Integer (SMI) \ No newline at end of file diff --git a/css/hux-blog.css b/css/hux-blog.css index 4e114d74285..f780d774cf1 100644 --- a/css/hux-blog.css +++ b/css/hux-blog.css @@ -1,8 +1,3 @@ -/*! - * Hux Blog v1.8.2 (http://huxpro.github.io) - * Copyright 2020 Hux - */ - @media (min-width: 1200px) { .post-container, .sidebar-container { diff --git a/css/hux-blog.min.css b/css/hux-blog.min.css index 0665f8b9c35..732c7d54837 100644 --- a/css/hux-blog.min.css +++ b/css/hux-blog.min.css @@ -1,6 +1 @@ -/*! - * Hux Blog v1.8.2 (http://huxpro.github.io) - * Copyright 2020 Hux - */ - @media (min-width:1200px){.post-container,.sidebar-container{padding-right:5%}}@media (min-width:768px){.post-container{padding-right:5%}}.sidebar-container{color:#bfbfbf;font-size:14px}.sidebar-container h5{color:#a3a3a3;padding-bottom:1em}.sidebar-container h5 a{color:#a3a3a3!important;text-decoration:none}.sidebar-container a{color:#bfbfbf!important}.sidebar-container a:hover,.sidebar-container a:active{color:#0085a1!important}.sidebar-container .tags a{border-color:#bfbfbf}.sidebar-container .tags a:hover,.sidebar-container .tags a:active{border-color:#0085a1}.sidebar-container .short-about img{width:80%;display:block;border-radius:5px;margin-bottom:20px}.sidebar-container .short-about p{margin-top:0;margin-bottom:20px}.sidebar-container .short-about .list-inline>li{padding-left:0}.catalog-container{padding:0}.side-catalog{display:block;overflow:auto;height:100%;padding-bottom:40px;width:195px}.side-catalog.fixed{position:fixed;top:-21px}.side-catalog.fold .catalog-toggle::before{content:"+"}.side-catalog.fold .catalog-body{display:none}.side-catalog .catalog-toggle::before{content:"−";position:relative;margin-right:5px;bottom:1px}.side-catalog .catalog-body{position:relative;list-style:none;height:auto;overflow:hidden;padding-left:0;padding-right:5px;text-indent:0}.side-catalog .catalog-body li{position:relative;list-style:none}.side-catalog .catalog-body li a{padding-left:10px;max-width:180px;display:inline-block;vertical-align:middle;height:30px;line-height:30px;overflow:hidden;text-decoration:none;white-space:nowrap;text-overflow:ellipsis}.side-catalog .catalog-body .h1_nav,.side-catalog .catalog-body .h2_nav{margin-left:0;font-size:13px;font-weight:700}.side-catalog .catalog-body .h3_nav{margin-left:6px;font-size:13px;font-weight:700}.side-catalog .catalog-body .h4_nav{margin-left:12px;font-size:12px}.side-catalog .catalog-body .h4_nav a{max-width:170px}.side-catalog .catalog-body .h5_nav .h6_nav{margin-left:18px;font-size:12px}.side-catalog .catalog-body .h5_nav .h6_nav a{max-width:170px}.side-catalog .catalog-body .active{border-radius:4px;background-color:#f5f5f5}.side-catalog .catalog-body .active a{color:#0085a1!important}@media (max-width:1200px){.side-catalog{display:none}}.paper-snackbar{transition-property:opacity,bottom,left,right,width,margin,border-radius;transition-duration:.5s;transition-timing-function:ease;font-size:14px;min-height:14px;background-color:#323232;background-color:#0085a1;position:fixed;display:flex;justify-content:space-between;align-items:center;color:#fff;line-height:22px;padding:18px 24px;bottom:0;opacity:0}@media (min-width:640px){.paper-snackbar{min-width:288px;max-width:568px;display:inline-flex;border-radius:2px;margin:24px;bottom:-100px}}@media (max-width:640px){.paper-snackbar{left:0;right:0}}.paper-snackbar .action{background:inherit;display:inline-block;border:none;font-size:inherit;text-transform:uppercase;color:#ffeb3b;margin:0 0 0 24px;padding:0;min-width:min-content;outline:0}.paper-button{position:relative;padding:4px 0;margin:1em;width:160px;overflow:hidden;user-select:none;color:#000;text-transform:uppercase;border-radius:3px;outline-color:#a3a3a3}.paper-button:hover{cursor:pointer}.paper-button button,.paper-button input[type=submit]{background:inherit;border:none;display:block;width:100%;height:100%;font-size:1em;color:#000;text-transform:uppercase}.paper-button.colored,.paper-button.colored button{color:#4285f4}.paper-button.raised-button.colored{background-color:#4285f4}.paper-button .raised-button{box-shadow:0 2px 5px 0 rgba(0,0,0,.26)}.paper-button.raised-button.colored{background:#4285f4;color:#fff}.paper-button[disabled]{background-color:#eaeaea!important;color:#a8a8a8!important;cursor:auto}.paper-button:hover{background-color:#eaeaea}.paper-button.raised-button.colored:hover{background-color:#3367d6}button.paper-button{border:0;font-size:1em;line-height:25px;background-color:#fff}.paper-button input[type=submit]{outline-color:#a3a3a3}.paper-button.colored.raised-button input[type=submit]{color:#fff}.paper-shadow-animated.paper-shadow{transition:box-shadow .28s cubic-bezier(0.4,0,.2,1)}.paper-shadow-top-z-1{box-shadow:0 2px 10px 0 rgba(0,0,0,.16)}.paper-shadow-bottom-z-1{box-shadow:0 2px 5px 0 rgba(0,0,0,.26)}.paper-shadow-top-z-2{box-shadow:0 6px 20px 0 rgba(0,0,0,.19)}.paper-shadow-bottom-z-2{box-shadow:0 8px 17px 0 rgba(0,0,0,.2)}.paper-shadow-top-z-3{box-shadow:0 17px 50px 0 rgba(0,0,0,.19)}.paper-shadow-bottom-z-3{box-shadow:0 12px 15px 0 rgba(0,0,0,.24)}.paper-shadow-top-z-4{box-shadow:0 25px 55px 0 rgba(0,0,0,.21)}.card{background:#fff;width:300px;height:300px;position:relative;margin:16px;border-radius:2px}.highlight,pre.highlight{background:#282c34;color:#abb2bf}.highlight pre{background:#282c34}.highlight .hll{background:#282c34}.highlight .c{color:#5c6370;font-style:italic}.highlight .err{color:#960050;background-color:#1e0010}.language-coq .highlight .err{background-color:transparent}.highlight .k,.language-coq .highlight .err{color:#c678dd}.highlight .l{color:#98c379}.highlight .n{color:#abb2bf}.highlight .o{color:#abb2bf}.highlight .p{color:#abb2bf}.highlight .cm{color:#5c6370;font-style:italic}.highlight .cp{color:#5c6370;font-style:italic}.highlight .c1{color:#5c6370;font-style:italic}.highlight .cs{color:#5c6370;font-style:italic}.highlight .ge{font-style:italic}.highlight .gs{font-weight:700}.highlight .kc{color:#c678dd}.highlight .kd{color:#c678dd}.highlight .kn{color:#c678dd}.highlight .kp{color:#c678dd}.highlight .kr{color:#c678dd}.highlight .kt{color:#c678dd}.highlight .ld{color:#98c379}.highlight .m{color:#d19a66}.highlight .s{color:#98c379}.highlight .na{color:#d19a66}.highlight .nb{color:#e5c07b}.highlight .nc{color:#e5c07b}.highlight .no{color:#e5c07b}.highlight .nd{color:#e5c07b}.highlight .ni{color:#e5c07b}.highlight .ne{color:#e5c07b}.highlight .nf{color:#abb2bf}.highlight .nl{color:#e5c07b}.highlight .nn{color:#abb2bf}.highlight .nx{color:#abb2bf}.highlight .py{color:#e5c07b}.highlight .nt{color:#e06c75}.highlight .nv{color:#e5c07b}.highlight .ow{font-weight:700}.highlight .w{color:#f8f8f2}.highlight .mf{color:#d19a66}.highlight .mh{color:#d19a66}.highlight .mi{color:#d19a66}.highlight .mo{color:#d19a66}.highlight .sb{color:#98c379}.highlight .sc{color:#98c379}.highlight .sd{color:#98c379}.highlight .s2{color:#98c379}.highlight .se{color:#98c379}.highlight .sh{color:#98c379}.highlight .si{color:#98c379}.highlight .sx{color:#98c379}.highlight .sr{color:#56b6c2}.highlight .s1{color:#98c379}.highlight .ss{color:#56b6c2}.highlight .bp{color:#e5c07b}.highlight .vc{color:#e5c07b}.highlight .vg{color:#e5c07b}.highlight .vi{color:#e06c75}.highlight .il{color:#d19a66}.highlight .gu{color:#75715e}.highlight .gd{color:#f92672}.highlight .gi{color:#a6e22e}.highlighter-rouge .highlight{margin-bottom:10px;border-radius:6px}.highlighter-rouge .highlight pre{font-size:14px;line-height:1.5;color:#555;background:0 0;border:0;margin:0;padding:0;word-wrap:normal}.highlighter-rouge .highlight .rouge-table .rouge-gutter,.highlighter-rouge .highlight .rouge-table .rouge-code{border:0!important}.highlighter-rouge .highlight .rouge-code pre{color:#abb2bf}.highlighter-rouge .highlight .table-responsive{margin:0;border:0}.highlighter-rouge .highlight .table{margin:0;table-layout:fixed}.highlighter-rouge .highlight table>tbody>tr>td{margin:0;border:0;padding:0}.highlighter-rouge .highlight table>tbody>tr>td>pre{padding:14px}.highlighter-rouge .highlight td.rouge-gutter{width:56px}.highlighter-rouge .highlight .lineno{text-align:right;border-radius:0}@media (max-width:480px){.highlighter-rouge .highlight{margin-left:-15px;margin-right:-15px;border-radius:0}.highlighter-rouge .highlight td.rouge-gutter{width:36px}.highlighter-rouge .highlight table>tbody>tr>td>pre{padding:14px 10px}}.search-page{position:fixed;top:0;right:0;bottom:0;left:0;z-index:100;background:#fff;-webkit-transition:all 400ms cubic-bezier(0.32,1,.23,1);transition:all 400ms cubic-bezier(0.32,1,.23,1);-webkit-transform:translate(0,100%);-ms-transform:translate(0,100%);transform:translate(0,100%);opacity:0}.search-page.search-active{opacity:1;-webkit-transform:translate(0,0) scale(1,1);-ms-transform:translate(0,0) scale(1,1);transform:translate(0,0) scale(1,1)}.search-page.search-active .search-main{opacity:1}.search-page .search-main{padding-top:80px;height:100%;opacity:0;-webkit-transition:all 400ms cubic-bezier(0.32,1,.23,1) 250ms;transition:all 400ms cubic-bezier(0.32,1,.23,1) 250ms}.search-page .search-main .row,.search-page .search-main .row>div{height:100%}.search-page .search-icon-close-container{position:absolute;z-index:1;padding:16px;top:0;right:2px}.search-page .search-icon-close-container i{font-size:20px}.search-page #search-input{font-family:"Fira Code",Menlo,Monaco,Consolas,"Courier New",monospace;border:none;outline:0;padding:0;margin:0;width:100%;font-size:30px;font-weight:700;color:#404040}@media only screen and (min-width:768px){.search-page #search-input{margin-left:20px}}.search-page #search-results{overflow:auto;height:100%;-webkit-overflow-scrolling:touch;padding-bottom:80px}.search-icon a,.search-icon-close{cursor:pointer;font-size:30px;color:#311e3e;-webkit-transition:all .25s;transition:all .25s}.search-icon a:hover,.search-icon-close:hover{opacity:.8}.search-icon,.search-icon-close{font-size:16px}body{font-family:-apple-system,BlinkMacSystemFont,"Helvetica Neue",Arial,"PingFang SC","Hiragino Sans GB",STHeiti,"Microsoft YaHei","Microsoft JhengHei","Source Han Sans SC","Noto Sans CJK SC","Source Han Sans CN","Noto Sans SC","Source Han Sans TC","Noto Sans CJK TC","WenQuanYi Micro Hei",SimSun,sans-serif;line-height:1.7;font-size:16px;color:#404040;overflow-x:hidden;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}p{margin:30px 0}@media screen and (max-width:768px){p{margin:25px 0}}h1,h2,h3,h4,h5,h6{font-family:-apple-system,BlinkMacSystemFont,"Helvetica Neue",Arial,"PingFang SC","Hiragino Sans GB",STHeiti,"Microsoft YaHei","Microsoft JhengHei","Source Han Sans SC","Noto Sans CJK SC","Source Han Sans CN","Noto Sans SC","Source Han Sans TC","Noto Sans CJK TC","WenQuanYi Micro Hei",SimSun,sans-serif;line-height:1.7;line-height:1.1;font-weight:700}h4{font-size:21px}a{color:#404040}a:hover,a:focus{color:#0085a1}a img:hover,a img:focus{cursor:zoom-in}article{overflow:hidden}blockquote{color:gray;font-style:italic;font-size:.95em;margin:20px 0 20px}blockquote p{margin:0}small.img-hint{display:block;margin-top:-20px;text-align:center}br+small.img-hint{margin-top:-40px}img.shadow{box-shadow:rgba(0,0,0,.258824) 0 2px 5px 0}select{-webkit-appearance:none;margin-top:15px;color:#337ab7;border-color:#337ab7;padding:0 .4em;background:#fff}select.sel-lang{min-height:28px;font-size:14px}table{margin-top:10px}table.table>tbody th,table.table>thead th,table.table>tbody td,table.table>thead td{border:1px solid #eee!important}@media screen and (max-width:767px){.table-responsive{border:0}}hr.small{max-width:100px;margin:15px auto;border-width:4px;border-color:#fff}pre,.table-responsive{-webkit-overflow-scrolling:touch}pre code{display:block;width:auto;white-space:pre;word-wrap:normal}code,kbd,pre,samp{font-family:"Fira Code",Menlo,Monaco,Consolas,"Courier New",monospace}.postlist-container{margin-bottom:15px}.post-container a{color:#337ab7}.post-container a:hover,.post-container a:focus{color:#0085a1}.post-container h1,.post-container h2,.post-container h3,.post-container h4,.post-container h5,.post-container h6{margin:50px 0 20px;line-height:1.4}.post-container h1+p,.post-container h2+p,.post-container h3+p,.post-container h4+p,.post-container h5+p,.post-container h6+p{margin-top:20px}.post-container h2::before{content:" ";display:block;border-bottom:1px solid #ececec;margin-top:44px;margin-bottom:30px}.post-container h4{font-size:22px;font-weight:600;color:gray}.post-container h4+p{margin-top:10px}.post-container h5,.post-container h6{font-size:20px;font-weight:600;color:gray}.post-container h5+p,.post-container h6+p{margin-top:10px}@media screen and (max-width:768px){.post-container h1{font-size:30px}.post-container h2{font-size:22px}.post-container h3{font-size:20px}.post-container h4{font-size:19px}.post-container h5,.post-container h6{font-size:18px}}.post-container ul,.post-container ol{margin-bottom:40px}@media screen and (max-width:768px){.post-container ul,.post-container ol{padding-left:30px}}@media screen and (max-width:500px){.post-container ul,.post-container ol{padding-left:20px}}.post-container ol ol,.post-container ol ul,.post-container ul ol,.post-container ul ul{margin-bottom:5px}.post-container li p{margin:0;margin-bottom:5px}.post-container li h1,.post-container li h2,.post-container li h3,.post-container li h4,.post-container li h5,.post-container li h6{line-height:2;margin-top:20px}.post-container .pager li{width:48%}.post-container .pager li.next{float:right}.post-container .pager li.previous{float:left}.post-container .pager li>a{width:100%}.post-container .pager li>a>span{color:#a3a3a3;font-weight:400;letter-spacing:.5px}.post-container .anchorjs-link{position:absolute;text-decoration:none!important}@media only screen and (max-width:767px){.navbar-default .navbar-collapse{position:absolute;right:0;border:none;background:#fff;box-shadow:0 5px 10px 2px rgba(0,0,0,.2);box-shadow:rgba(0,0,0,.117647) 0 1px 6px,rgba(0,0,0,.239216) 0 1px 4px;border-radius:2px;width:170px}#huxblog_navbar{opacity:0;transform:scaleX(0);transform-origin:top right;transition:all 200ms cubic-bezier(0.47,0,.4,.99) 0ms;-webkit-transform:scaleX(0);-webkit-transform-origin:top right;-webkit-transition:all 200ms cubic-bezier(0.47,0,.4,.99) 0ms}#huxblog_navbar a{font-size:13px;line-height:28px}#huxblog_navbar .navbar-collapse{height:0;transform:scaleY(0);transform-origin:top right;transition:transform 400ms cubic-bezier(0.32,1,.23,1) 0ms;-webkit-transform:scaleY(0);-webkit-transform-origin:top right;-webkit-transition:-webkit-transform 400ms cubic-bezier(0.32,1,.23,1) 0ms}#huxblog_navbar li{opacity:0;transition:opacity 100ms cubic-bezier(0.23,1,.32,1) 0ms;-webkit-transition:opacity 100ms cubic-bezier(0.23,1,.32,1) 0ms}#huxblog_navbar.in{transform:scaleX(1);-webkit-transform:scaleX(1);opacity:1;transition:all 250ms cubic-bezier(0.23,1,.32,1) 0ms;-webkit-transition:all 250ms cubic-bezier(0.23,1,.32,1) 0ms}#huxblog_navbar.in .navbar-collapse{transform:scaleY(1);-webkit-transform:scaleY(1);transition:transform 500ms cubic-bezier(0.23,1,.32,1);-webkit-transition:-webkit-transform 500ms cubic-bezier(0.23,1,.32,1)}#huxblog_navbar.in li{opacity:1;transition:opacity 450ms cubic-bezier(0.23,1,.32,1) 205ms;-webkit-transition:opacity 450ms cubic-bezier(0.23,1,.32,1) 205ms}}.navbar-custom{background:0 0;border:none;position:absolute;top:0;left:0;width:100%;z-index:3;font-family:-apple-system,BlinkMacSystemFont,"Helvetica Neue",Arial,"PingFang SC","Hiragino Sans GB",STHeiti,"Microsoft YaHei","Microsoft JhengHei","Source Han Sans SC","Noto Sans CJK SC","Source Han Sans CN","Noto Sans SC","Source Han Sans TC","Noto Sans CJK TC","WenQuanYi Micro Hei",SimSun,sans-serif;line-height:1.7}.navbar-custom .navbar-brand{font-weight:800;color:#fff;height:56px;line-height:25px}.navbar-custom .navbar-brand:hover{color:rgba(255,255,255,.8)}.navbar-custom .nav li a{text-transform:uppercase;font-size:12px;line-height:20px;font-weight:800;letter-spacing:1px}.navbar-custom .nav li a:active{background:rgba(0,0,0,.12)}@media only screen and (min-width:768px){.navbar-custom{background:0 0;border-bottom:1px solid transparent}.navbar-custom body{font-size:20px}.navbar-custom .navbar-brand{color:#fff;padding:20px;line-height:20px}.navbar-custom .navbar-brand:hover,.navbar-custom .navbar-brand:focus{color:rgba(255,255,255,.8)}.navbar-custom .nav li a{color:#fff;padding:20px}.navbar-custom .nav li a:hover,.navbar-custom .nav li a:focus{color:rgba(255,255,255,.8)}.navbar-custom .nav li a:active{background:0 0}}.navbar-custom.invert .navbar-toggle:active{background-color:rgba(0,0,0,.05)}.navbar-custom.invert .navbar-toggle .icon-bar{background-color:#404040}.navbar-custom.invert .navbar-brand{color:#404040}.navbar-custom.invert .navbar-brand:hover,.navbar-custom.invert .navbar-brand:focus{color:#0085a1}.navbar-custom.invert .nav li a{color:#404040}.navbar-custom.invert .nav li a:hover,.navbar-custom.invert .nav li a:focus{color:#0085a1}@media only screen and (min-width:1170px){.navbar-custom{-webkit-transition:background-color .3s;-moz-transition:background-color .3s;transition:background-color .3s;-webkit-transform:translate3d(0,0,0);-moz-transform:translate3d(0,0,0);-ms-transform:translate3d(0,0,0);-o-transform:translate3d(0,0,0);transform:translate3d(0,0,0);-webkit-backface-visibility:hidden;backface-visibility:hidden}.navbar-custom.is-fixed{position:fixed;top:-61px;background-color:rgba(255,255,255,.9);border-bottom:1px solid #f2f2f2;-webkit-transition:-webkit-transform .3s;-moz-transition:-moz-transform .3s;transition:transform .3s}.navbar-custom.is-fixed .navbar-brand{color:#404040}.navbar-custom.is-fixed .navbar-brand:hover,.navbar-custom.is-fixed .navbar-brand:focus{color:#0085a1}.navbar-custom.is-fixed .nav li a{color:#404040}.navbar-custom.is-fixed .nav li a:hover,.navbar-custom.is-fixed .nav li a:focus{color:#0085a1}.navbar-custom.is-visible{-webkit-transform:translate3d(0,100%,0);-moz-transform:translate3d(0,100%,0);-ms-transform:translate3d(0,100%,0);-o-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0)}}.intro-header{background:no-repeat center center;background-color:#a3a3a3;background-attachment:scroll;-webkit-background-size:cover;-moz-background-size:cover;background-size:cover;-o-background-size:cover;margin-bottom:0}.intro-header.style-text{background:0 0}.intro-header.style-text .site-heading,.intro-header.style-text .post-heading,.intro-header.style-text .page-heading{padding:85px 0 20px;color:#404040}.intro-header.style-text .site-heading .subheading,.intro-header.style-text .post-heading .subheading,.intro-header.style-text .page-heading .subheading{margin-bottom:15px}.intro-header.style-text .tags a,.intro-header.style-text .tags .tag{border-color:#404040;color:#404040}.intro-header.style-text .tags a:hover,.intro-header.style-text .tags .tag:hover,.intro-header.style-text .tags a:active,.intro-header.style-text .tags .tag:active{background-color:rgba(0,0,0,.05)}@media only screen and (min-width:768px){.intro-header{margin-bottom:20px}}.intro-header .site-heading,.intro-header .post-heading,.intro-header .page-heading{padding:85px 0 55px;color:#fff}@media only screen and (min-width:768px){.intro-header .site-heading,.intro-header .post-heading,.intro-header .page-heading{padding:150px 0}}.intro-header .site-heading{padding:95px 0 70px}@media only screen and (min-width:768px){.intro-header .site-heading{padding:150px 0}}.intro-header .site-heading,.intro-header .page-heading{text-align:center}.intro-header .site-heading h1,.intro-header .page-heading h1{margin-top:0;font-size:50px}.intro-header .site-heading .subheading,.intro-header .page-heading .subheading{font-family:-apple-system,BlinkMacSystemFont,"Helvetica Neue",Arial,"PingFang SC","Hiragino Sans GB",STHeiti,"Microsoft YaHei","Microsoft JhengHei","Source Han Sans SC","Noto Sans CJK SC","Source Han Sans CN","Noto Sans SC","Source Han Sans TC","Noto Sans CJK TC","WenQuanYi Micro Hei",SimSun,sans-serif;line-height:1.7;font-size:18px;line-height:1.1;display:block;font-weight:300;margin:10px 0 0}@media only screen and (min-width:768px){.intro-header .site-heading h1,.intro-header .page-heading h1{font-size:80px}}.intro-header .post-heading h1{font-size:30px;margin-bottom:24px}.intro-header .post-heading .subheading,.intro-header .post-heading .meta{line-height:1.1;display:block}.intro-header .post-heading .subheading{font-family:-apple-system,BlinkMacSystemFont,"Helvetica Neue",Arial,"PingFang SC","Hiragino Sans GB",STHeiti,"Microsoft YaHei","Microsoft JhengHei","Source Han Sans SC","Noto Sans CJK SC","Source Han Sans CN","Noto Sans SC","Source Han Sans TC","Noto Sans CJK TC","WenQuanYi Micro Hei",SimSun,sans-serif;line-height:1.7;font-size:17px;line-height:1.4;font-weight:400;margin:10px 0 30px;margin-top:-5px}.intro-header .post-heading .meta{font-family:Lora,'Times New Roman',serif;font-style:italic;font-weight:300;font-size:16px}.intro-header .post-heading .meta a{color:#fff}@media only screen and (min-width:768px){.intro-header .post-heading h1{font-size:55px}.intro-header .post-heading .subheading{font-size:30px}.intro-header .post-heading .meta{font-size:20px}}.intro-header .header-img-credit{position:absolute;bottom:6px;right:9px;color:#fff;opacity:.3;font-size:10px;z-index:1}.intro-header .header-img-credit a{color:#fff}@media only screen and (min-width:768px){.intro-header .header-img-credit{font-size:12px;bottom:10px;right:15px}}.post-preview>a{color:#404040}.post-preview>a:hover,.post-preview>a:focus{text-decoration:none;color:#0085a1}.post-preview>a>.post-title{font-size:21px;line-height:1.3;margin-top:30px;margin-bottom:8px}.post-preview>a>.post-subtitle{font-size:15px;line-height:1.3;margin:0;font-weight:300;margin-bottom:10px}.post-preview>.post-meta{font-family:Lora,'Times New Roman',serif;color:#a3a3a3;font-size:16px;font-style:italic;margin-top:0}.post-preview>.post-meta>a{text-decoration:none;color:#404040}.post-preview>.post-meta>a:hover,.post-preview>.post-meta>a:focus{color:#0085a1;text-decoration:underline}@media only screen and (min-width:768px){.post-preview>a>.post-title{font-size:26px;line-height:1.3;margin-bottom:10px}.post-preview>a>.post-subtitle{font-size:16px}.post-preview .post-meta{font-size:18px}}.post-content-preview{font-size:13px;font-style:italic;color:#a3a3a3}.post-content-preview:hover{color:#0085a1}@media only screen and (min-width:768px){.post-content-preview{font-size:14px}}.section-heading{font-size:36px;margin-top:60px;font-weight:700}.caption{text-align:center;font-size:14px;padding:10px;font-style:italic;margin:0;display:block;border-bottom-right-radius:5px;border-bottom-left-radius:5px}footer{font-size:20px;padding:50px 0 65px}footer .list-inline{margin:0;padding:0}footer .copyright{font-size:14px;text-align:center;margin-bottom:0}footer .copyright a{color:#337ab7}footer .copyright a:hover,footer .copyright a:focus{color:#0085a1}.btn{font-family:-apple-system,BlinkMacSystemFont,"Helvetica Neue",Arial,"PingFang SC","Hiragino Sans GB",STHeiti,"Microsoft YaHei","Microsoft JhengHei","Source Han Sans SC","Noto Sans CJK SC","Source Han Sans CN","Noto Sans SC","Source Han Sans TC","Noto Sans CJK TC","WenQuanYi Micro Hei",SimSun,sans-serif;line-height:1.7;text-transform:uppercase;font-size:14px;font-weight:800;letter-spacing:1px;border-radius:0;padding:15px 25px}.btn-lg{font-size:16px;padding:25px 35px}.btn-default:hover,.btn-default:focus{background-color:#0085a1;border:1px solid #0085a1;color:#fff}.pager{margin:20px 0 0!important;padding:0!important}.pager li>a,.pager li>span{font-family:-apple-system,BlinkMacSystemFont,"Helvetica Neue",Arial,"PingFang SC","Hiragino Sans GB",STHeiti,"Microsoft YaHei","Microsoft JhengHei","Source Han Sans SC","Noto Sans CJK SC","Source Han Sans CN","Noto Sans SC","Source Han Sans TC","Noto Sans CJK TC","WenQuanYi Micro Hei",SimSun,sans-serif;line-height:1.7;text-transform:uppercase;font-size:13px;font-weight:800;letter-spacing:1px;padding:10px;background-color:#fff;border-radius:0}@media only screen and (min-width:768px){.pager li>a,.pager li>span{font-size:14px;padding:15px 25px}}.pager li>a{color:#404040}.pager li>a:hover,.pager li>a:focus{color:#fff;background-color:#0085a1;border:1px solid #0085a1}.pager li>a:hover>span,.pager li>a:focus>span{color:#fff}.pager .disabled>a,.pager .disabled>a:hover,.pager .disabled>a:focus,.pager .disabled>span{color:#a3a3a3;background-color:#404040;cursor:not-allowed}::-moz-selection{color:#fff;text-shadow:none;background:#0085a1}::selection{color:#fff;text-shadow:none;background:#0085a1}img::selection{color:#fff;background:0 0}img::-moz-selection{color:#fff;background:0 0}.d-none{display:none!important}.tags{margin-bottom:-5px}.tags.tags-sup a,.tags.tags-sup .tag{padding:0 10px 0 12px}.tags a,.tags .tag{display:inline-block;border:1px solid rgba(255,255,255,.8);border-radius:999em;padding:0 10px 0 10px;color:#fff;line-height:24px;font-size:12px;text-decoration:none;margin:0 1px;margin-bottom:6px;cursor:pointer}.tags a>sup,.tags .tag>sup{margin-left:-2px;font-weight:700}.tags a:hover,.tags .tag:hover,.tags a:active,.tags .tag:active{color:#fff;border-color:#fff;background-color:rgba(255,255,255,.4);text-decoration:none}@media only screen and (min-width:768px){.tags a,.tags .tag{margin-right:5px}}#tag-heading{padding:70px 0 60px}@media only screen and (min-width:768px){#tag-heading{padding:55px 0}}#tag_cloud{margin:20px 0 15px 0}#tag_cloud a,#tag_cloud .tag{transition-property:all;transition-duration:.4s;transition-timing-function:ease;font-size:14px;border:none;line-height:28px;margin:0 2px;margin-bottom:8px;background:#f3f5f5}#tag_cloud a:hover,#tag_cloud .tag:hover,#tag_cloud a:active,#tag_cloud .tag:active,#tag_cloud a.focus,#tag_cloud .tag.focus{background-color:#0085a1!important}#tag_cloud a.focus,#tag_cloud .tag.focus{box-shadow:rgba(0,0,0,.117647) 0 1px 6px,rgba(0,0,0,.239216) 0 1px 4px}#tag_cloud a.tag-button--all,#tag_cloud .tag.tag-button--all{font-weight:700;color:#0085a1!important}#tag_cloud a.tag-button--all:hover,#tag_cloud .tag.tag-button--all:hover,#tag_cloud a.tag-button--all:active,#tag_cloud .tag.tag-button--all:active,#tag_cloud a.tag-button--all.focus,#tag_cloud .tag.tag-button--all.focus{background-color:#e4e4e4!important}@media only screen and (min-width:768px){#tag_cloud{margin-bottom:25px}}.tag-comments{font-size:12px}@media only screen and (min-width:768px){.tag-comments{font-size:14px}}.t:first-child{margin-top:0}.listing-seperator{color:#0085a1;font-size:21px!important}.listing-seperator::before{margin-right:5px}@media only screen and (min-width:768px){.listing-seperator{font-size:20px!important;line-height:2!important}}.mini-post-list{margin:20px 0 15px 0}.mini-post-list .tag-text{font-weight:200;font-family:-apple-system,BlinkMacSystemFont,"Helvetica Neue",Arial,"PingFang SC","Hiragino Sans GB",STHeiti,"Microsoft YaHei","Microsoft JhengHei","Source Han Sans SC","Noto Sans CJK SC","Source Han Sans CN","Noto Sans SC","Source Han Sans TC","Noto Sans CJK TC","WenQuanYi Micro Hei",SimSun,sans-serif;line-height:1.7}.mini-post-list .post-preview{position:relative}.mini-post-list .post-preview>a .post-title{font-size:16px;font-weight:500;margin-top:20px}.mini-post-list .post-preview>a .post-subtitle{font-size:13px}.mini-post-list .post-preview>.post-meta{position:absolute;right:5px;bottom:0;margin:0;font-size:12px;line-height:12px}@media only screen and (min-width:768px){.mini-post-list .post-preview{margin-left:20px}.mini-post-list .post-preview>a>.post-title{font-size:18px;line-height:1.3}.mini-post-list .post-preview>a>.post-subtitle{font-size:14px}.mini-post-list .post-preview .post-meta{font-size:18px}}.post-container img{display:block;max-width:100%;height:auto;margin:1.5em auto 1.6em auto}.navbar-default .navbar-toggle:focus,.navbar-default .navbar-toggle:hover{background-color:inherit}.navbar-default .navbar-toggle:active{background-color:rgba(255,255,255,.25)}.navbar-default .navbar-toggle{border-color:transparent;padding:19px 16px;margin-top:2px;margin-right:2px;margin-bottom:2px;border-radius:50%}.navbar-default .navbar-toggle .icon-bar{width:18px;border-radius:0;background-color:#fff}.navbar-default .navbar-toggle .icon-bar+.icon-bar{margin-top:3px}.page-fullscreen .intro-header{position:fixed;left:0;top:0;width:100%;height:100%}.page-fullscreen #tag-heading{position:fixed;left:0;top:0;padding-bottom:150px;width:100%;height:100%;display:-webkit-box;-webkit-box-orient:vertical;-webkit-box-pack:center;-webkit-box-align:center;display:-webkit-flex;-webkit-align-items:center;-webkit-justify-content:center;-webkit-flex-direction:column;display:flex;align-items:center;justify-content:center;flex-direction:column}.page-fullscreen footer{position:absolute;width:100%;bottom:0;padding-bottom:20px;opacity:.6;color:#fff}.page-fullscreen footer .copyright{color:#fff}.page-fullscreen footer .copyright a{color:#fff}.page-fullscreen footer .copyright a:hover{color:#ddd}.MathJax_SVG_Display{overflow:auto;-webkit-overflow-scrolling:touch}.no-scroll{overflow-y:hidden} \ No newline at end of file diff --git a/js/hux-blog.min.js b/js/hux-blog.min.js index 4d271b7e8bf..33fdfa93526 100644 --- a/js/hux-blog.min.js +++ b/js/hux-blog.min.js @@ -1,6 +1 @@ -/*! - * Hux Blog v1.8.2 (http://huxpro.github.io) - * Copyright 2020 Hux - */ - $(document).ready(function(){$("table").wrap("
"),$("table").addClass("table")}),$(document).ready(function(){$('iframe[src*="youtube.com"]').wrap('
'),$('iframe[src*="youtube.com"]').addClass("embed-responsive-item"),$('iframe[src*="vimeo.com"]').wrap('
'),$('iframe[src*="vimeo.com"]').addClass("embed-responsive-item")}),jQuery(document).ready(function(i){var a,o;1170