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
Codex の「自走力」を高める
yorifuji
0
1.2k
ベクトル検索のフィルタを用いた機械学習モデルとの統合 / python-meetup-fukuoka-06-vector-attr
monochromegane
2
390
Takumiから考えるSecurity_Maturity_Model.pdf
gessy0129
1
140
Claude Codeログ基盤の構築
giginet
PRO
7
2.7k
nuget-server - あなたが必要だったNuGetサーバー
kekyo
PRO
0
230
Agentic AI: Evolution oder Revolution
mobilelarson
PRO
0
150
どんと来い、データベース信頼性エンジニアリング / Introduction to DBRE
nnaka2992
1
270
15年目のiOSアプリを1から作り直す技術
teakun
1
620
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
210
ふつうの Rubyist、ちいさなデバイス、大きな一年
bash0c7
0
830
Go1.26 go fixをプロダクトに適用して困ったこと
kurakura0916
0
360
SourceGeneratorのマーカー属性問題について
htkym
0
180
Featured
See All Featured
A Soul's Torment
seathinner
5
2.4k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
190
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
290
Technical Leadership for Architectural Decision Making
baasie
3
280
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
120
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
1.9k
KATA
mclloyd
PRO
35
15k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
130
Side Projects
sachag
455
43k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
140
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
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.