Changeset 1361
- Timestamp:
- 04/19/08 09:25:20 (6 months ago)
- Files:
-
- mochikit/trunk/doc/html/MochiKit/Format.html (modified) (3 diffs)
- mochikit/trunk/doc/rst/MochiKit/Format.rst (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
mochikit/trunk/doc/html/MochiKit/Format.html
r1276 r1361 165 165 <p> 166 166 <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("%.2f%%",</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 170 maximum precision of 2 fractional digits. Roughly equivalent to: 171 <tt class="docutils literal"><span class="pre">sprintf("%.2f%%",</span> <span class="pre">aNumber</span> <span class="pre">*</span> <span class="pre">100)</span></tt></p> 170 172 <p>In new code, you probably want to use: 171 <a class="mochiref reference" href="#fn-numberformatter">numberFormatter("#.##%")( someFloat)</a> instead.</p>173 <a class="mochiref reference" href="#fn-numberformatter">numberFormatter("#.##%")(aNumber)</a> instead.</p> 172 174 <dl class="docutils"> 173 175 <dt><em>Availability</em>:</dt> … … 243 245 <blockquote> 244 246 <p>Calculate an average from a numerator and a denominator and return 245 it as a string with two digits of precision (e.g. "1.23").</p> 247 it as a string rounded to a maximum precision of two fractional 248 digits (e.g. "1.23").</p> 246 249 <p>If the denominator is 0, "0" will be returned instead of <tt class="docutils literal"><span class="pre">NaN</span></tt>.</p> 247 250 <dl class="docutils"> … … 252 255 <p> 253 256 <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("%.2f",</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("#.##")(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 260 precision 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 262 the 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> 264 and <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("#.##")(aNumber)</a> instead.</p> 259 267 <dl class="docutils"> 260 268 <dt><em>Availability</em>:</dt> mochikit/trunk/doc/rst/MochiKit/Format.rst
r1039 r1361 133 133 134 134 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)`` 138 140 139 141 In new code, you probably want to use: 140 :mochiref:`numberFormatter("#.##%")( someFloat)` instead.142 :mochiref:`numberFormatter("#.##%")(aNumber)` instead. 141 143 142 144 *Availability*: … … 206 208 207 209 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"). 209 212 210 213 If the denominator is 0, "0" will be returned instead of ``NaN``. … … 214 217 215 218 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. 222 231 223 232 *Availability*:
