Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Little Twelve Toes
Search
Cameron Price
October 27, 2016
Programming
0
75
Little Twelve Toes
Extending Elixir to support base-12 numbering
Cameron Price
October 27, 2016
Tweet
Share
More Decks by Cameron Price
See All by Cameron Price
Make it Fast: The Power of Benchmarking
cameronp
2
40
Other Decks in Programming
See All in Programming
TerraformとStrands AgentsでAmazon Bedrock AgentCoreのSSO認証付きエージェントを量産しよう!
neruneruo
4
2.3k
脳の「省エネモード」をデバッグする ~System 1(直感)と System 2(論理)の切り替え~
panda728
PRO
0
130
ゆくKotlin くるRust
exoego
1
190
GoLab2025 Recap
kuro_kurorrr
0
1.1k
実はマルチモーダルだった。ブラウザの組み込みAI🧠でWebの未来を感じてみよう #jsfes #gemini
n0bisuke2
3
1.4k
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
220
DevFest Android in Korea 2025 - 개발자 커뮤니티를 통해 얻는 가치
wisemuji
0
180
Developing static sites with Ruby
okuramasafumi
1
340
Navigation 3: 적응형 UI를 위한 앱 탐색
fornewid
1
520
AI Agent Dojo #4: watsonx Orchestrate ADK体験
oniak3ibm
PRO
0
120
Deno Tunnel を使ってみた話
kamekyame
0
310
Vibe codingでおすすめの言語と開発手法
uyuki234
0
160
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Side Projects
sachag
455
43k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
41
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
0
84
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.8k
Facilitating Awesome Meetings
lara
57
6.7k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.3k
HDC tutorial
michielstock
1
300
Mobile First: as difficult as doing things right
swwweet
225
10k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
0
400
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
Transcript
Little Twelve-Toes Extending Elixir to Support Base-12 Numbers
Little who?
None
None
None
If only this had been the norm…
Better??
Yes!
10 = 5 * 2
10 = 5 * 2 12 = 3 * 2
* 2
10 = 5 * 2 12 = 3 * 2
* 2 = 3 * 4 = 2 * 6
1,2,3,4,5,6,7,8,9,X,E, 10,11,12,13,14,15,16,17,18,19,1X, 1E,20
But this is kinda… uncomfortable, isn’t it?
Yeah, because the English language is base-10 also…
Solution: a new language for numbers
0..9 : The same 10 : X (pronounced ‘dec’) 11
: E (pronounced ‘el’) 12 : 10 (pronounced ‘do’)
13: 11 (do one) 14 :12 (do two) etc.. 24
: 20 (two do)
10: do 100: gro 1000: mo 10000: do-mo
Now we can say: 32X7 is “three mo two gro
dec do seven”
Now we can say: 32X7 is “three mo two gro
dec do seven” Easy peasy…
What’s this gotta do with Elixir?
Well, I got to wondering, how extensible is Elixir?
Introducing: Dozenex (https://github.com/cameronp/ dozenex)
In an ideal world: Decimal: 15 Hex: 0x0F Dozenal: 0d13
Unfortunately… it doesn’t look like you can add new number
formats
Compromise: Sigils!
def sigil_d(s, []), do: s |> String.split(".") |> _construct def
_construct([w]), do: w |> Dozenex.Integer. construct
iex(2)> ~d(13E) %Dozenex.Integer{digits: [1, 3, 11]} iex(3)>
defimpl String.Chars, for: Dozenex.Integer do def to_string(%Dozenex.Integer{digits: digits}) , do:
digits |> Dozenex.Integer. _convert_to_char_list |> Kernel.to_string end defimpl Inspect, for: Dozenex.Integer do def inspect(di, _opts), do: "~d(#{di})" end
iex(2)> ~d(13E) ~d(13E) iex(3)>
iex(6)> ~d(13E) |> Dozenex.Math.add(~d(22X)) ~d(369)
iex(7)> ~d(13E) |> Dozenex.to_doz_words "one gro three do el"
Ok, what’s missing?
NYI • Infix operators for +, -, *, /, and
..
NYI • Infix operators for +, -, *, /, and
.. • Floating point support
NYI • Infix operators for +, -, *, /, and
.. • Floating point support • Mixed Dozenal / Decimal math
PR’s welcome! (cameronp/ dozenex)
Learn more: • http://dozenal.org/ (The Dozenal Society of America) •
https://en.wikipedia.org/wiki/Duodecimal • https://en.wikipedia.org/wiki/Decimal#Other_bases
Thanks! I am cameronp on github, twitter, medium, gmail, and
the elixir slack team.