Numeric to Yllion

バージョン 1.5.5 (12 KB) 作成者: Stephen23
Convert a numeric to text giving the value using Donald Knuth's Yllion naming scheme.

ダウンロード 355 件

更新 2022/1/31

ライセンスの表示

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 = 'Negative Ten Hundred Myriad Myllion Tryllion Sextyllion'
>> 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'

引用

Stephen23 (2022). Numeric to Yllion (https://www.mathworks.com/matlabcentral/fileexchange/51261-numeric-to-yllion), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2010b
R2009b 以降と互換性あり
プラットフォームの互換性
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!