File Exchange

version 1.3.2 (5.94 KB) by
Convert a number to a string giving the value using Knuth's Myriad/Yllion naming scheme.

Updated 09 Jul 2020

Convert a numeric scalar into a string giving the number value using Donald Knuth's Myriad (aka -Yllion) number naming scheme, e.g. 1024e6 -> 'Ten Myllion Twenty-Four Hundred Myriad', or '10;2400,0000' as digits.

Syntax:

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.

### Myriad System (aka -Yllion) ###

Donald Knuth's Myriad 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^8 myllion
10^16 byllion
10^32 tryllion
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:
http://en.wikipedia.org/wiki/-yllion
http://mrob.com/pub/math/largenum-2.html

### Examples ###

ans = 'Zero'

ans = 'Ten Hundred Twenty-Four'

ans = 'Negative Three Myriad Twenty-Seven Hundred Sixty-Eight'
ans = '-3,2768'

ans = 'Ninety-Eight Myllion Seventy-Six Hundred Fifty-Four Myriad Thirty-Two Hundred Ten'
ans = '98;7654,3210'

ans = '1::0000,0000;0000,0000:0000,0000;0000,0000;;0000,0000;0000,0000:0000,0000;0000,0000'

>> num2myriad(1e303) % aka one centillion (short scale)
ans = 'Ten Hundred Myriad Myllion Tryllion Sextyllion'

### Cite As

Stephen Cobeldick (2020). Number to Myriad (https://www.mathworks.com/matlabcentral/fileexchange/51261-number-to-myriad), MATLAB Central File Exchange. Retrieved .

 9 Jul 2020 1.3.2 * Add error IDs. 29 Feb 2020 1.3.1 * Include test function. 23 Sep 2017 1.3.0.0 * Correct zip file. 23 Sep 2017 1.3.0.0 * Improve help. 11 Sep 2015 1.3.0.0 * Edit blurb. 8 Sep 2015 1.2.0.0 * Fix bug in myriad parsing (if >1 highest level multiplier). 23 Jun 2015 1.1.0.0 * Replace tabs with four space characters. * Improve index calculation. 22 Jun 2015 1.0.0.0 * Add image
##### MATLAB Release Compatibility
Created with R2010b
Compatible with any release
##### Platform Compatibility
Windows macOS Linux