Changeset 1361

Show
Ignore:
Timestamp:
04/19/08 09:25:20 (6 months ago)
Author:
cederberg@gmail.com
Message:

Updated docs for MochiKit.Format.percentFormat(), twoDigitAverage() and twoDigitFloat() to better reflect the current implementation and test suite.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mochikit/trunk/doc/html/MochiKit/Format.html

    r1276 r1361  
    165165<p> 
    166166<a name="fn-percentformat"></a> 
    167 <a class="mochidef reference" href="#fn-percentformat">percentFormat(someFloat)</a>:</p> 
    168 <blockquote> 
    169 <p>Roughly equivalent to: <tt class="docutils literal"><span class="pre">sprintf(&quot;%.2f%%&quot;,</span> <span class="pre">someFloat</span> <span class="pre">*</span> <span class="pre">100)</span></tt></p> 
     167<a class="mochidef reference" href="#fn-percentformat">percentFormat(aNumber)</a>:</p> 
     168<blockquote> 
     169<p>Return a string representation of <tt class="docutils literal"><span class="pre">aNumber</span> <span class="pre">*</span> <span class="pre">100</span></tt>, rounded to a 
     170maximum precision of 2 fractional digits. Roughly equivalent to: 
     171<tt class="docutils literal"><span class="pre">sprintf(&quot;%.2f%%&quot;,</span> <span class="pre">aNumber</span> <span class="pre">*</span> <span class="pre">100)</span></tt></p> 
    170172<p>In new code, you probably want to use: 
    171 <a class="mochiref reference" href="#fn-numberformatter">numberFormatter(&quot;#.##%&quot;)(someFloat)</a> instead.</p> 
     173<a class="mochiref reference" href="#fn-numberformatter">numberFormatter(&quot;#.##%&quot;)(aNumber)</a> instead.</p> 
    172174<dl class="docutils"> 
    173175<dt><em>Availability</em>:</dt> 
     
    243245<blockquote> 
    244246<p>Calculate an average from a numerator and a denominator and return 
    245 it as a string with two digits of precision (e.g. &quot;1.23&quot;).</p> 
     247it as a string rounded to a maximum precision of two fractional 
     248digits (e.g. &quot;1.23&quot;).</p> 
    246249<p>If the denominator is 0, &quot;0&quot; will be returned instead of <tt class="docutils literal"><span class="pre">NaN</span></tt>.</p> 
    247250<dl class="docutils"> 
     
    252255<p> 
    253256<a name="fn-twodigitfloat"></a> 
    254 <a class="mochidef reference" href="#fn-twodigitfloat">twoDigitFloat(someFloat)</a>:</p> 
    255 <blockquote> 
    256 <p>Roughly equivalent to: <tt class="docutils literal"><span class="pre">sprintf(&quot;%.2f&quot;,</span> <span class="pre">someFloat)</span></tt></p> 
    257 <p>In new code, you probably want to use 
    258 <a class="mochiref reference" href="#fn-numberformatter">numberFormatter(&quot;#.##&quot;)(someFloat)</a> instead.</p> 
     257<a class="mochidef reference" href="#fn-twodigitfloat">twoDigitFloat(aNumber)</a>:</p> 
     258<blockquote> 
     259<p>Return a string representation of <tt class="docutils literal"><span class="pre">aNumber</span></tt>, rounded to a maximum 
     260precision of 2 fractional digits. This is a variation of 
     261<a class="mochiref reference" href="#fn-roundtofixed">roundToFixed(aNumber, 2)</a> that removes trailing zeros from 
     262the fractional part.</p> 
     263<p>For example, <tt class="docutils literal"><span class="pre">twoDigitFloat(0.1357)</span></tt> returns <tt class="docutils literal"><span class="pre">0.14</span></tt> 
     264and <tt class="docutils literal"><span class="pre">twoDigitFloat(12.00)</span></tt> returns <tt class="docutils literal"><span class="pre">12</span></tt>.</p> 
     265<p>In new code, you probably want to use: 
     266<a class="mochiref reference" href="#fn-numberformatter">numberFormatter(&quot;#.##&quot;)(aNumber)</a> instead.</p> 
    259267<dl class="docutils"> 
    260268<dt><em>Availability</em>:</dt> 
  • mochikit/trunk/doc/rst/MochiKit/Format.rst

    r1039 r1361  
    133133 
    134134 
    135 :mochidef:`percentFormat(someFloat)`: 
    136  
    137     Roughly equivalent to: ``sprintf("%.2f%%", someFloat * 100)`` 
     135:mochidef:`percentFormat(aNumber)`: 
     136 
     137    Return a string representation of ``aNumber * 100``, rounded to a 
     138    maximum precision of 2 fractional digits. Roughly equivalent to: 
     139    ``sprintf("%.2f%%", aNumber * 100)`` 
    138140 
    139141    In new code, you probably want to use: 
    140     :mochiref:`numberFormatter("#.##%")(someFloat)` instead. 
     142    :mochiref:`numberFormatter("#.##%")(aNumber)` instead. 
    141143 
    142144    *Availability*: 
     
    206208 
    207209    Calculate an average from a numerator and a denominator and return 
    208     it as a string with two digits of precision (e.g. "1.23"). 
     210    it as a string rounded to a maximum precision of two fractional 
     211    digits (e.g. "1.23"). 
    209212 
    210213    If the denominator is 0, "0" will be returned instead of ``NaN``. 
     
    214217 
    215218 
    216 :mochidef:`twoDigitFloat(someFloat)`: 
    217  
    218     Roughly equivalent to: ``sprintf("%.2f", someFloat)`` 
    219  
    220     In new code, you probably want to use 
    221     :mochiref:`numberFormatter("#.##")(someFloat)` instead. 
     219:mochidef:`twoDigitFloat(aNumber)`: 
     220 
     221    Return a string representation of ``aNumber``, rounded to a maximum 
     222    precision of 2 fractional digits. This is a variation of 
     223    :mochiref:`roundToFixed(aNumber, 2)` that removes trailing zeros from 
     224    the fractional part. 
     225 
     226    For example, ``twoDigitFloat(0.1357)`` returns ``0.14`` 
     227    and ``twoDigitFloat(12.00)`` returns ``12``. 
     228 
     229    In new code, you probably want to use: 
     230    :mochiref:`numberFormatter("#.##")(aNumber)` instead. 
    222231 
    223232    *Availability*: