$30 off During Our Annual Pro Sale. View Details »
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
38
Other Decks in Programming
See All in Programming
[SF Ruby Conf 2025] Rails X
palkan
0
430
tparseでgo testの出力を見やすくする
utgwkk
1
130
【CA.ai #3】Google ADKを活用したAI Agent開発と運用知見
harappa80
0
260
「文字列→日付」の落とし穴 〜Ruby Date.parseの意外な挙動〜
sg4k0
0
360
AIエージェントを活かすPM術 AI駆動開発の現場から
gyuta
0
220
新卒エンジニアのプルリクエスト with AI駆動
fukunaga2025
0
110
『実践MLOps』から学ぶ DevOps for ML
nsakki55
2
550
全員アーキテクトで挑む、 巨大で高密度なドメインの紐解き方
agatan
8
18k
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
400
スタートアップを支える技術戦略と組織づくり
pospome
8
15k
手軽に積ん読を増やすには?/読みたい本と付き合うには?
o0h
PRO
1
140
無秩序からの脱却 / Emergence from chaos
nrslib
2
12k
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.2k
Site-Speed That Sticks
csswizardry
13
990
What's in a price? How to price your products and services
michaelherold
246
12k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
54k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
1k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
The Language of Interfaces
destraynor
162
25k
Optimizing for Happiness
mojombo
379
70k
Git: the NoSQL Database
bkeepers
PRO
432
66k
Context Engineering - Making Every Token Count
addyosmani
9
460
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.3k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
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.