aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Powers <markppowers0@gmail.com>2018-12-10 21:56:08 -0500
committerMark Powers <markppowers0@gmail.com>2018-12-10 21:56:08 -0500
commit1f9960f92337a84f3f642ed27b66e97d75939ef7 (patch)
tree2e0b342500def0427bcfc5c7c638203fdb1c7ce1
parent841ea9a04cedbc99b15b85ed13778ac7abb4572d (diff)
Add css changes
-rw-r--r--src/css/styles.css8
-rw-r--r--src/html/bread.html20
-rw-r--r--src/html/essay.html7
-rw-r--r--src/html/essay/magic-division.html111
-rw-r--r--src/html/index.html3
5 files changed, 82 insertions, 67 deletions
diff --git a/src/css/styles.css b/src/css/styles.css
index 90d3f1a..b8bc0aa 100644
--- a/src/css/styles.css
+++ b/src/css/styles.css
@@ -25,7 +25,7 @@ img {
.card {
margin: 3em;
- border: 1px solid #777777;
+ border: 1px solid #777777;
}
.card img {
@@ -64,3 +64,9 @@ img {
text-align: center;
font-size: 20px;
}
+
+.date {
+ font-style: italic;
+ margin-left: 2em;
+ margin-top: 1em;
+} \ No newline at end of file
diff --git a/src/html/bread.html b/src/html/bread.html
index 774b0e6..7ad3b41 100644
--- a/src/html/bread.html
+++ b/src/html/bread.html
@@ -21,7 +21,7 @@
banneton, leaving a lot of residue.</p>
<img src="photo/pretty.jpg">
<br>
- <p>Dec 4, 2018</p>
+ <p class="date">Dec 4, 2018</p>
</div>
</div>
<div class="card">
@@ -31,7 +31,7 @@
<img src="photo/pizza1.jpg">
<img src="photo/pizza2.jpg">
<br>
- <p>Nov 21, 2018</p>
+ <p class="date">Nov 21, 2018</p>
</div>
</div>
<div class="card">
@@ -40,7 +40,7 @@
<img src="photo/good1.jpg">
<img src="photo/good2.jpg">
<br>
- <p>Nov 16, 2018</p>
+ <p class="date">Nov 16, 2018</p>
</div>
</div>
<div class="card">
@@ -49,7 +49,7 @@
and corn flours. A bit dense, but not bad.</p>
<img src="photo/wheat.jpg">
<br>
- <p>Sep 30, 2018</p>
+ <p class="date">Sep 30, 2018</p>
</div>
</div>
<div class="card">
@@ -57,7 +57,7 @@
<p class="card-text">A twist on normal beer bread, using hard cider.</p>
<img src="photo/cider.jpg">
<br>
- <p>Sep 30, 2018</p>
+ <p class="date">Sep 30, 2018</p>
</div>
</div>
<div class="card">
@@ -67,7 +67,7 @@
<img src="photo/nyt1.jpg">
<img src="photo/nyt2.jpg">
<br>
- <p>Sep 27, 2018</p>
+ <p class="date">Sep 27, 2018</p>
</div>
</div>
<div class="card">
@@ -77,7 +77,7 @@
<img src="photo/ban1.jpg">
<img src="photo/ban2.jpg">
<br>
- <p>Sep 19, 2018</p>
+ <p class="date">Sep 19, 2018</p>
</div>
</div>
<div class="card">
@@ -87,7 +87,7 @@
<img src="photo/flat1.jpg">
<img src="photo/flat2.jpg">
<br>
- <p>Aug 30, 2018</p>
+ <p class="date">Aug 30, 2018</p>
</div>
</div>
<div class="card">
@@ -96,7 +96,7 @@
<img src="photo/white-1.jpg">
<img src="photo/white-2.jpg">
<br>
- <p>Aug 16, 2018</p>
+ <p class="date">Aug 16, 2018</p>
</div>
</div>
<div class="card">
@@ -105,7 +105,7 @@
<img src="photo/first-1.jpg">
<img src="photo/first-2.jpg">
<br>
- <p>Aug 9, 2018</p>
+ <p class="date">Aug 9, 2018</p>
</div>
</div>
</div>
diff --git a/src/html/essay.html b/src/html/essay.html
index 3b419b6..7110df1 100644
--- a/src/html/essay.html
+++ b/src/html/essay.html
@@ -1,8 +1,8 @@
<!doctype html>
<html lang="en">
-
+
<head>
- <title>Mark's Kitchen - Essay</title>
+ <title>Mark's Kitchen - Essays</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" type="text/css" href="/css/bootstrap.css">
@@ -12,7 +12,7 @@
<body>
<div class="container">
<br>
- <h1>Essay</h1>
+ <h1>Essays</h1>
<div class="feed">
<div class="card">
<div class="card-body">
@@ -22,6 +22,7 @@
</p>
<a href="essay/magic-division.html" class="btn btn-primary">Read</a>
</div>
+ <p class="date">Dec 8, 2018</p>
</div>
</div>
</div>
diff --git a/src/html/essay/magic-division.html b/src/html/essay/magic-division.html
index f40048d..10849b3 100644
--- a/src/html/essay/magic-division.html
+++ b/src/html/essay/magic-division.html
@@ -1,69 +1,74 @@
<!doctype html>
<html lang="en">
- <head>
- <title>Magic Division</title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
-
- </head>
- <body>
+
+<head>
+ <title>Magic Division</title>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+
+</head>
+
+<body>
<link rel="stylesheet" type="text/css" href="/css/styles.css">
<div class="essay">
<h2>Magic Division -- Or Division by Integer Multiplication</h2>
- <p>I noticed something strange in the assembly generated when compiling a program
+ <p>I noticed something strange in the assembly generated when compiling a program
using <code>gcc</code> an optimization turned off. Here it is in <a href="#figure1">Figure 1</a>
(though using optimization level 3 just to simplify, but it still shows in level 0).
- In this generated assembly, we see instead of using the <code>div</code> operator,
- something strange is going on with the number 1717986919 and shifting. My first
- attempts at searching for this phenomenon online were not helpful. The first result
- for the number was on Amazon as a book identifier. This number also shows up on
- stack overflow, however it is no more helpful. No one on the post is talking about
- why this number is in the generated code (or perhaps they all know this arcane
- secret and don’t wish share). Eventually, I found out what was going on. Even
- with no optimization, the compiler prefers to generate multiplication operator
+ In this generated assembly, we see instead of using the <code>div</code> operator,
+ something strange is going on with the number 1717986919 and shifting. My first
+ attempts at searching for this phenomenon online were not helpful. The first result
+ for the number was on Amazon as a book identifier. This number also shows up on
+ stack overflow, however it is no more helpful. No one on the post is talking about
+ why this number is in the generated code (or perhaps they all know this arcane
+ secret and don’t wish share). Eventually, I found out what was going on. Even
+ with no optimization, the compiler prefers to generate multiplication operator
over the division operator.
</p>
- <p>We will consider unsigned integer division first. Let
- <span class="math inline"><em>d</em></span>
- be some constant divisor, and <span class="math inline"><em>n</em></span>
- our numerator (for now let’s make <span class="math inline"><em>n</em></span>
- a multiple of <span class="math inline"><em>d</em></span>). We will assume
- integers are 32 bits. In order to computer
- <span class="math inline"><em>n</em>/<em>d</em></span>,
- first we need to know the values <span class="math inline"><em>l</em></span>
- and <span class="math inline"><em>i</em></span> where
- <span class="math inline"><em>d</em> = <em>l</em>2<sup><em>i</em></sup></span>.
- So to begin out division, we can shift <span class="math inline"><em>n</em></span>
- by <span class="math inline"><em>i</em></span> bits. Now we must divide this result
- be <span class="math inline"><em>l</em></span>. Since
- <span class="math inline"><em>l</em></span> will be odd, there exists some
- inverse of <span class="math inline"><em>l</em></span>, called
+ <p>We will consider unsigned integer division first. Let
+ <span class="math inline"><em>d</em></span>
+ be some constant divisor, and <span class="math inline"><em>n</em></span>
+ our numerator (for now let’s make <span class="math inline"><em>n</em></span>
+ a multiple of <span class="math inline"><em>d</em></span>). We will assume
+ integers are 32 bits. In order to computer
+ <span class="math inline"><em>n</em>/<em>d</em></span>,
+ first we need to know the values <span class="math inline"><em>l</em></span>
+ and <span class="math inline"><em>i</em></span> where
+ <span class="math inline"><em>d</em> = <em>l</em>2<sup><em>i</em></sup></span>.
+ So to begin out division, we can shift <span class="math inline"><em>n</em></span>
+ by <span class="math inline"><em>i</em></span> bits. Now we must divide this result
+ be <span class="math inline"><em>l</em></span>. Since
+ <span class="math inline"><em>l</em></span> will be odd, there exists some
+ inverse of <span class="math inline"><em>l</em></span>, called
<span class="math inline"><em>j</em></span> where <br />
- <span class="math display"><em>l</em><em>j</em> = 1(mod 2<sup>32</sup>)</span><br />
- So for any number <span class="math inline"><em>x</em></span>,
- <span class="math inline"><em>x</em>/<em>l</em> = (<em>x</em><em>j</em>)/(<em>l</em><em>j</em>)=<em>x</em><em>j</em></span>.
- So now all that is left after the shift is to multiply by
- <span class="math inline"><em>j</em></span>, and we will
+ <span class="math display"><em>l</em><em>j</em> = 1(mod 2<sup>32</sup>)</span><br />
+ So for any number <span class="math inline"><em>x</em></span>,
+ <span class="math inline"><em>x</em>/<em>l</em> = (<em>x</em><em>j</em>)/(<em>l</em><em>j</em>)=<em>x</em><em>j</em></span>.
+ So now all that is left after the shift is to multiply by
+ <span class="math inline"><em>j</em></span>, and we will
have computed <span class="math inline"><em>n</em>/<em>d</em></span>.</p>
- <p>Dealing with remainder can go pretty in depth, and I recommend
- reading the chapter in Hacker’s Delight about this topic
+ <p>Dealing with remainder can go pretty in depth, and I recommend
+ reading the chapter in Hacker’s Delight about this topic
<a class="citation" href="#hacker">[1]</a>. Another write up can be found
in the MSDN blog archive <a class="citation" href="#msdn">[2]</a>.
</p>
<div class="figure">
- <a name="figure1"><h4>Figure 1</h4></a>
- <span>Source:</span>
- <div class="sourceCode" frame="single" numbers="left" language="c">
- <pre><code class="sourceCode">
+ <a name="figure1">
+ <h4>Figure 1</h4>
+ </a>
+ <span>Source:</span>
+ <div class="sourceCode" frame="single" numbers="left" language="c">
+ <pre><code class="sourceCode">
int div20(int n){
return a/20;
}
- </code></pre></div>
- <span>Compiled excerpt:</span>
- <div class="sourceCode" frame="single" numbers="left">
- <pre><code class="sourceCode">
+ </code></pre>
+ </div>
+ <span>Compiled excerpt:</span>
+ <div class="sourceCode" frame="single" numbers="left">
+ <pre><code class="sourceCode">
.cfi_startproc
movl %edi, %eax
movl $1717986919, %edx
@@ -74,22 +79,24 @@ movl %edx, %eax
subl %edi, %eax
ret
.cfi_endproc
- </code></pre></div>
+ </code></pre>
+ </div>
</div>
<h3>References</h3>
- <p><a name="hacker">1</a> Hacker’s Delight Chapter 10.
+ <p><a name="hacker">1</a> Hacker’s Delight Chapter 10.
(<em><a href="http://www.hackersdelight.org/divcMore.pdf">
- http://www.hackersdelight.org/divcMore.pdf
+ http://www.hackersdelight.org/divcMore.pdf
</a>
</em>)
</p>
- <p><a name="msdn">2</a> MSDN Blog Archive
+ <p><a name="msdn">2</a> MSDN Blog Archive
(<em><a href="https://blogs.msdn.microsoft.com/devdev/2005/12/12/integer-division-by-constants/">
- https://blogs.msdn.microsoft.com/devdev/2005/12/12/integer-division-by-constants/
+ https://blogs.msdn.microsoft.com/devdev/2005/12/12/integer-division-by-constants/
</a>
</em>)
</p>
</div>
- </body>
+</body>
+
</html> \ No newline at end of file
diff --git a/src/html/index.html b/src/html/index.html
index ed90fe7..087cf5b 100644
--- a/src/html/index.html
+++ b/src/html/index.html
@@ -20,9 +20,10 @@
<div class="card item">
<div class="card-body">
<p class="card-text">
- Come check out my gallery of homemade bread, featuring mainly artisan sourdough.
+ Welcome to marks.kitchen. Check out my <a href="/bread">bread</a>!
</p>
</div>
+ <p class="date">Dec 10, 2018</p>
</div>
</div>
</body>