<doc>
  <legacy_id>1223</legacy_id>
  <name>numberFormat</name>
  <type>property</type>
  <syntax>
    <example>set the numberFormat [of <i>scrollbar</i>] to <i>formatExpression</i></example>
  </syntax>
  <library></library>
  <objects>
    <local/>
  </objects>
  <synonyms>
  </synonyms>
  <classification>
    <category>Math, Logic, &amp; Dates</category>
  </classification>
  <references>
    <command tag="multiply">multiply Command</command>
    <function tag="format">format Function</function>
  </references>
  <history>
    <introduced version="1.0">Added.</introduced>
  </history>
  <platforms>
    <mac/>
    <windows/>
    <linux/>
    <ios/>
    <android/>
  </platforms>
  <classes>
    <desktop/>
    <server/>
    <web/>
    <mobile/>
  </classes>
  <security>
  </security>
  <summary>Specifies how many digits before and after the <glossary tag="decimal point">decimal point</glossary> a computed number should have.</summary>
  <examples>
    <example>set the numberFormat to "#.00" <i>-- dollar format</i></example>
    <example>set the numberFormat of scrollbar "Progress" to "0.0"</example>
  </examples>
  <description>
    <p>Use the <b>numberFormat</b> <glossary tag="property">property</glossary> to specify the results of <keyword tag="numeric">numeric</keyword> calculations, or the display of numbers in <glossary tag="scrollbar">scrollbars</glossary> whose <property tag="showValue">showValue</property> <glossary tag="property">property</glossary> is set to true.</p><p/><p><b>Value:</b></p><p>The <b>numberFormat</b> consists of any combination of a string of zeros and a string of hash marks (#), separated by a <glossary tag="decimal point">decimal point</glossary>. (If the <b>numberFormat</b> contains hash marks, it must be surrounded by quotes; otherwise the first hash mark is interpreted as the start of a <glossary tag="comment">comment</glossary>.)</p><p/><p>By default, the <b>numberFormat</b> <glossary tag="property">property</glossary> is set to 0.######. The <b>numberFormat</b> of newly created <glossary tag="scrollbar">scrollbars</glossary> is set to empty.</p><p/><p><b>Comments:</b></p><p>The number of zeros or hash marks before the decimal point indicates how many digits are shown before the decimal point. If the result of a calculation has fewer digits before the decimal point than there are zeros or hash marks in the <b>numberFormat</b>, leading zeros are added. If the calculated result has more digits before the <glossary tag="decimal point">decimal point</glossary> than there are zeros or hash marks, all the digits are displayed.</p><p/><p>If there are zeros after the decimal point, the number of zeros indicates the number of digits after the decimal point in a calculated number. If there are more digits after the decimal point, the number is truncated. If there are fewer digits, trailing zeros are added.</p><p/><p>If there are hash marks after the decimal point, the number of hash marks indicates the maximum number of digits after the decimal point. If there are more digits, the number is truncated, but if there are fewer digits, no trailing zeroes are added.</p><p/><p>The default <b>numberFormat</b> is 0.######, meaning that the results of calculations are reported with at least one digit before the decimal point, and up to 6 digits after the <glossary tag="decimal point">decimal point</glossary>.</p><p/><p><img src="202653"/> <b>Important!</b> Changing the <b>numberFormat</b> does not automatically change the <function tag="format">format</function> of a number that's already in a <glossary tag="container">container</glossary>. It affects numbers only when they are calculated and then displayed or used as <glossary tag="string">strings</glossary>. Otherwise, the number retains its full <keyword tag="numeric">numeric</keyword> <glossary tag="precision">precision</glossary>.</p><p/><p>Since the <b>numberFormat</b> is a <href tag="../dictionary/local_property.xml">local property</href>, its value is <command tag="reset">reset</command> to 0.###### when the current handler finishes <glossary tag="execute">executing</glossary>. It retains its <function tag="value">value</function> only for the current <glossary tag="handler">handler</glossary>, and setting it in one <glossary tag="handler">handler</glossary> does not affect its value in other <glossary tag="handler">handlers</glossary> it <glossary tag="call">calls</glossary>. (The <b>numberFormat</b> of a <keyword tag="scrollbar">scrollbar</keyword> is not <command tag="reset">reset</command> in this way.)</p><p/><p><b>Note:</b> Since LiveCode does not use decimal numbers for its internal calculations (for reasons of speed), the decimal representation of a number is sometimes slightly off the correct number. For example, 10^-1 is equal to 0.1, but is calculated (to eighteen decimal places) as 0.100000000000000006. Because of this, setting the <b>numberFormat</b> to specify many decimal places after the decimal point may produce unexpected results in a <glossary tag="statement">statement</glossary> that tests for an exact number. To prevent this, either avoid setting the <b>numberFormat</b> to a value more precise than you need, or use the <function tag="abs">abs</function> <control_st tag="function">function</control_st> instead of the <operator tag="=">=</operator> <glossary tag="operator">operator</glossary> to test equality:</p><p/><p>  set the numberformat to ".##################"</p><p>  put 10^-1 = 0.1 -- reports false because of the decimal error</p><p>  put abs((10^-1) - 0.1) = zero -- reports true</p><p/>
  </description>
</doc>