forked from erikwiffin/0.30000000000000004
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b67cf7c
commit 221e7ad
Showing
56 changed files
with
641 additions
and
547 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
_site | ||
.sass-cache | ||
.jekyll-metadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
source "https://rubygems.org" | ||
ruby RUBY_VERSION | ||
|
||
# Hello! This is where you manage which Jekyll version is used to run. | ||
# When you want to use a different version, change it below, save the | ||
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so: | ||
# | ||
# bundle exec jekyll serve | ||
# | ||
# This will help ensure the proper Jekyll version is running. | ||
# Happy Jekylling! | ||
gem "jekyll", "3.4.3" | ||
|
||
# This is the default theme for new Jekyll sites. You may change this to anything you like. | ||
gem "minima", "~> 2.0" | ||
|
||
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and | ||
# uncomment the line below. To upgrade, run `bundle update github-pages`. | ||
# gem "github-pages", group: :jekyll_plugins | ||
|
||
# If you have any plugins, put them here! | ||
group :jekyll_plugins do | ||
gem "jekyll-feed", "~> 0.6" | ||
end | ||
|
||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem | ||
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
addressable (2.5.1) | ||
public_suffix (~> 2.0, >= 2.0.2) | ||
colorator (1.1.0) | ||
ffi (1.9.18) | ||
forwardable-extended (2.6.0) | ||
jekyll (3.4.3) | ||
addressable (~> 2.4) | ||
colorator (~> 1.0) | ||
jekyll-sass-converter (~> 1.0) | ||
jekyll-watch (~> 1.1) | ||
kramdown (~> 1.3) | ||
liquid (~> 3.0) | ||
mercenary (~> 0.3.3) | ||
pathutil (~> 0.9) | ||
rouge (~> 1.7) | ||
safe_yaml (~> 1.0) | ||
jekyll-feed (0.9.2) | ||
jekyll (~> 3.3) | ||
jekyll-sass-converter (1.5.0) | ||
sass (~> 3.4) | ||
jekyll-watch (1.5.0) | ||
listen (~> 3.0, < 3.1) | ||
kramdown (1.13.2) | ||
liquid (3.0.6) | ||
listen (3.0.8) | ||
rb-fsevent (~> 0.9, >= 0.9.4) | ||
rb-inotify (~> 0.9, >= 0.9.7) | ||
mercenary (0.3.6) | ||
minima (2.1.1) | ||
jekyll (~> 3.3) | ||
pathutil (0.14.0) | ||
forwardable-extended (~> 2.6) | ||
public_suffix (2.0.5) | ||
rb-fsevent (0.9.8) | ||
rb-inotify (0.9.8) | ||
ffi (>= 0.5.0) | ||
rouge (1.11.1) | ||
safe_yaml (1.0.4) | ||
sass (3.4.23) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
jekyll (= 3.4.3) | ||
jekyll-feed (~> 0.6) | ||
minima (~> 2.0) | ||
tzinfo-data | ||
|
||
RUBY VERSION | ||
ruby 2.4.0p0 | ||
|
||
BUNDLED WITH | ||
1.14.6 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Welcome to Jekyll! | ||
# | ||
# This config file is meant for settings that affect your whole blog, values | ||
# which you are expected to set up once and rarely edit after that. If you find | ||
# yourself editing this file very often, consider using Jekyll's data files | ||
# feature for the data you need to update frequently. | ||
# | ||
# For technical reasons, this file is *NOT* reloaded automatically when you use | ||
# 'bundle exec jekyll serve'. If you change this file, please restart the server process. | ||
|
||
# Site settings | ||
# These are used to personalize your new site. If you look in the HTML files, | ||
# you will see them accessed via {{ site.title }}, {{ site.email }}, and so on. | ||
# You can create any custom variable you would like, and they will be accessible | ||
# in the templates via {{ site.myvariable }}. | ||
title: Your awesome title | ||
email: [email protected] | ||
description: > # this means to ignore newlines until "baseurl:" | ||
Write an awesome description for your new site here. You can edit this | ||
line in _config.yml. It will appear in your document head meta (for | ||
Google search results) and in your feed.xml site description. | ||
baseurl: "" # the subpath of your site, e.g. /blog | ||
url: "" # the base hostname & protocol for your site, e.g. http://example.com | ||
|
||
# Build settings | ||
markdown: kramdown | ||
gems: | ||
- jekyll-feed | ||
exclude: | ||
- Gemfile | ||
- Gemfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<div> | ||
<p> | ||
I am Erik Wiffin. | ||
You can contact me at: | ||
<a href="http://erik.wiffin.com">erik.wiffin.com</a> | ||
or | ||
<a href="mailto:[email protected]">[email protected]</a>. | ||
</p> | ||
<p> | ||
This project is on <a href="https://github.com/erikwiffin/0.30000000000000004">github</a>. | ||
If you think this page could be improved, send me a pull request. | ||
</p> | ||
</div> | ||
|
||
<!-- Google Analytics --> | ||
<script type="text/javascript"> | ||
|
||
var _gaq = _gaq || []; | ||
_gaq.push(['_setAccount', 'UA-8267311-11']); | ||
_gaq.push(['_trackPageview']); | ||
|
||
(function() { | ||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; | ||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; | ||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); | ||
})(); | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
<title>{% if page.title %}{{ page.title }}{% else %}{{ site.name }}{% endif %}</title> | ||
|
||
<link rel="canonical" href="{{ site.url}}{{ site.baseurl }}" /> | ||
|
||
<!-- CSS --> | ||
<link rel="stylesheet" href="{{ site.baseurl }}/styles.css" type="text/css"> | ||
|
||
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
{% include head.html %} | ||
<body> | ||
{{ content }} | ||
|
||
{% include footer.html %} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
layout: default | ||
--- | ||
<div> | ||
<h1>Floating Point Math</h1> | ||
<p> | ||
Your language isn't broken, it's doing floating point math. | ||
Computers can only natively store integers, | ||
so they need some way of representing decimal numbers. | ||
This representation comes with some degree of inaccuracy. | ||
That's why, more often than not, <code>.1 + .2 != .3</code>. | ||
</p> | ||
|
||
<h3>Why does this happen?</h3> | ||
<p> | ||
It's actually pretty simple. When you have a base 10 system (like ours), | ||
it can only express fractions that use a prime factor of the base. | ||
The prime factors of 10 are 2 and 5. So 1/2, 1/4, 1/5, 1/8, and 1/10 | ||
can all be expressed cleanly because the denominators all use prime factors of 10. | ||
In contrast, 1/3, 1/6, and 1/7 are all repeating decimals because their denominators use a prime factor of 3 or 7. | ||
In binary (or base 2), the only prime factor is 2. So you can only express fractions cleanly which only contain 2 as a prime factor. | ||
In binary, 1/2, 1/4, 1/8 would all be expressed cleanly as decimals. | ||
While, 1/5 or 1/10 would be repeating decimals. | ||
So 0.1 and 0.2 (1/10 and 1/5) while clean decimals in a base 10 system, are repeating decimals in the base 2 system the computer is operating in. | ||
When you do math on these repeating decimals, you end up with leftovers which carry | ||
over when you convert the computer's base 2 (binary) number into a more human readable base 10 number. | ||
</p> | ||
|
||
<p> | ||
Below are some examples of sending <code>.1 + .2</code> | ||
to standard output in a variety of languages. | ||
</p> | ||
<p align="center"> | ||
read more: | ||
| | ||
<a href="http://en.wikipedia.org/wiki/Floating_point">wikipedia</a> | ||
| | ||
<a href="http://grouper.ieee.org/groups/754/">IEEE 754</a> | ||
| | ||
<a href="http://stackoverflow.com/questions/588004/is-javascripts-math-broken/588014">Stack Overflow</a> | ||
</p> | ||
</div> | ||
|
||
<table cellpadding="0" cellspacing="5"> | ||
<tr> | ||
<th>Language</th> | ||
<th>Code</th> | ||
<th>Result</th> | ||
</tr> | ||
{% for post in site.posts reversed %} | ||
<tr> | ||
<td>{{ post.title }}</td> | ||
<td> | ||
{% if post.code.first %} | ||
{% for code in post.code %} | ||
<pre><code>{{ code | xml_escape }}</code></pre> | ||
{% if forloop.last %}{% else %}And{% endif %} | ||
{% endfor %} | ||
{% else %} | ||
<pre><code>{{ post.code | xml_escape }}</code></pre> | ||
{% endif %} | ||
</td> | ||
<td> | ||
{% if post.result.first %} | ||
{% for result in post.result %} | ||
{{ result | markdownify }} | ||
{% if forloop.last %}{% else %}And{% endif %} | ||
{% endfor %} | ||
{% else %} | ||
{{ post.result | markdownify }} | ||
{% endif %} | ||
</td> | ||
</tr> | ||
{% if post.excerpt.size > 1 %} | ||
<tr> | ||
<td colspan="3" class="comment">{{ post.excerpt }}</td> | ||
</tr> | ||
{% endif %} | ||
{% endfor %} | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
layout: default | ||
--- | ||
<header> | ||
<div class="header-small"> | ||
<a href="{{ site.url }}{{ site.baseurl }}">{{ site.name }}</a> | ||
</div> | ||
</header> | ||
<div class="page"> | ||
<div class="page-title">{{ page.title }}</div> | ||
{{ content }} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
layout: default | ||
--- | ||
<header> | ||
<div class="header-small"> | ||
<a href="{{ site.url }}{{ site.baseurl }}">{{ site.name }}</a> | ||
</div> | ||
</header> | ||
<div class="post"> | ||
{{ content }} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
layout: post | ||
title: "ABAP" | ||
code: | ||
- WRITE / CONV f( '.1' + '.2' ). | ||
- WRITE / CONV decfloat16( '.1' + '.2' ). | ||
result: | ||
- 3.0000000000000004E-01 | ||
- 0.3 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
layout: post | ||
title: "bc" | ||
code: 0.1 + 0.2 | ||
result: 0.3 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
layout: post | ||
title: "C" | ||
code: |- | ||
#include<stdio.h> | ||
int main(int argc, char** argv) { | ||
printf("%.17f\n", .1+.2); | ||
return 0; | ||
} | ||
result: 0.30000000000000004 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
layout: post | ||
title: "Clojure" | ||
code: "(+ 0.1 0.2)" | ||
result: "0.30000000000000004" | ||
--- | ||
Clojure supports arbitrary precision and ratios. <code>(+ 0.1M 0.2M)</code> returns <code>0.3M</code>, while <code>(+ 1/10 2/10)</code> returns <code>3/10</code>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
layout: post | ||
title: "Common Lisp" | ||
code: | ||
- '* (+ .1 .2)' | ||
- '* (+ 1/10 2/10)' | ||
result: | ||
- 0.3 | ||
- 3/10 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
layout: post | ||
title: "C++" | ||
code: |- | ||
#include <iomanip> | ||
std::cout << setprecision(17) << 0.1 + 0.2 | ||
result: 0.30000000000000004 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
layout: post | ||
title: "C#" | ||
code: 'Console.WriteLine("{0:R}", .1 + .2);' | ||
result: "0.30000000000000004" | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
layout: post | ||
title: "D" | ||
code: |- | ||
import std.stdio; | ||
void main(string[] args) { | ||
writefln("%.17f", .1+.2); | ||
writefln("%.17f", .1f+.2f); | ||
writefln("%.17f", .1L+.2L); | ||
} | ||
result: |- | ||
0.29999999999999999 | ||
0.30000001192092896 | ||
0.30000000000000000 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
layout: post | ||
title: "dc" | ||
code: "0.1 0.2 + p" | ||
result: ".3" | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
layout: post | ||
title: "Delphi XE5" | ||
code: "writeln(0.1 + 0.2);" | ||
result: "3.00000000000000E-0001" | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
layout: post | ||
title: "Elixir" | ||
code: "IO.puts(0.1 + 0.2)" | ||
result: "0.30000000000000004" | ||
--- |
Oops, something went wrong.