Numeric to Yllion
version 1.5.5 (12 KB) by
Stephen23
Convert a numeric to text giving the value using Donald Knuth's Yllion naming scheme.
Convert a numeric scalar into text giving the number value using Donald Knuth's Yllion number naming scheme, e.g. 1024e6 -> 'Ten Myllion Twenty-Four Hundred Myriad', or '10;2400,0000' as digits.
Syntax:
txt = num2yllion(num)
txt = num2yllion(num,dgt)
txt = num2yllion(num,dgt,pfx)
The input numeric value is rounded and the output precision is defined to ensure the least-unexpected output: single=6 digits; double=15 digits; while int/uint values are parsed at their full precision. The function implements an efficient algorithm without using recursion and with just one for-loop.
Yllion System
Donald Knuth's Yllion number naming system uses a logarithmic increase in group magnitudes for a much more efficient usage of the group names:
- 10^0 one
- 10^1 ten
- 10^2 hundred
- 10^4 myriad
- 10^8 myllion
- 10^16 byllion
- 10^32 tryllion
- 10^64 quadryllion
- 10^128 quintyllion
- 10^256 sextyllion
Knuth defined the pronunciation as "a myllion (pronounced mile-yun)".
Original Reference: "Supernatural Numbers" by Donald E. Knuth (pp. 310-325 in The Mathematical Gardner, editor David A. Klarner, 1981). Online References:
Examples
>> num2yllion(0)
ans ='Zero'
>> num2yllion(-1e303)% aka one centillion (short scale)
ans =“负一千无数Myllion Tryllion两边yllion'
>> num2yllion(9876543210)
ans ='Ninety-Eight Myllion Seventy-Six Hundred Fifty-Four Myriad Thirty-Two Hundred Ten'
>> num2yllion(9876543210,true)
ans ='98;7654,3210'
>> num2yllion(9876543210,true,true)
ans ='+98;7654,3210'
>> num2yllion(9876543210,false,true)
ans ='Positive Ninety-Eight Myllion Seventy-Six Hundred Fifty-Four Myriad Thirty-Two Hundred Ten'
>> num2yllion(1e64,false)% default
ans ='One Quadryllion'
>> num2yllion(1e64,true)
ans ='1::0000,0000;0000,0000:0000,0000;0000,0000;;0000,0000;0000,0000:0000,0000;0000,0000'
Cite As
Stephen23 (2022).Numeric to Yllion(//www.tianjin-qmedu.com/matlabcentral/fileexchange/51261-numeric-to-yllion), MATLAB Central File Exchange. Retrieved.
MATLAB Release Compatibility
Created with R2010b
Compatible with R2009b and later releases
Platform Compatibility
Windows macOS LinuxTags
Acknowledgements
Inspired by:text2speech - tts,num2english,text-to-speech,Variable Precision Integer Arithmetic,Number to Scientific Prefix,Text2Speech for Matlab using unofficial google service,Date Vector/Number to ISO 8601 Date String,Customizable Natural-Order Sort,ISO 8601 Date String to Serial Date Number,Numeric to Ordinal-String,Number to Words,Convert number to words
Inspired:Words to Number,Number to Words
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.