http://learn.cemetech.net/index.php?title=TI-BASIC:Multiply&feed=atom&action=historyTI-BASIC:Multiply - Revision history2024-03-29T10:38:42ZRevision history for this page on the wikiMediaWiki 1.34.0http://learn.cemetech.net/index.php?title=TI-BASIC:Multiply&diff=1192&oldid=prevMaintenance script: Initial automated import2016-02-24T18:39:23Z<p>Initial automated import</p>
<p><b>New page</b></p><div>{{Template:TI-BASIC:Command<br />
|picture=MULTIPLY.GIF<br />
|summary=Returns the multiplication of two numbers.<br />
|syntax=''value1'' * ''value2''<br />
|location=Press [*]<br />
|compatibility=TI-83/84/+/SE<br />
|size=1 byte<br />
}}<br />
<br />
The * (multiply) operator takes two numbers, variables, or expressions and multiplies their values together, thus returning a single new value. The * operator appears higher in the order of operations than both [[TI-BASIC:Add|+]] and [[TI-BASIC:Subtract|-]], so if those appear in an expression, * will be executed first. In addition, the [[TI-BASIC:Divide|/]] operator has the same order of operations as *, so the calculator simply executes them left to right in the order that they appear.<br />
<br />
:1*1<br />
1<br />
<br />
:5→X<br />
:2*3X<br />
30<br />
<br />
:2→A:3→B<br />
:A/B*B/A<br />
1<br />
<br />
= Advanced Uses =<br />
<br />
As it turns out, the most advanced way to use * is by not using it at all. On z80-based TI calculators, two adjacent expressions or variables are implicilty multiplied even without a * mark.<br />
<br />
:5*A<br />
should be<br />
:5A<br />
<br />
:5*cos(N*θ<br />
should be<br />
:5cos(Nθ<br />
<br />
There are a few cases in which omitting the multiplication sign doesn't work. For example, 2^4*[[TI-BASIC:Size_75%|Size_75%]][[TI-BASIC:E_Ten|E]][[TI-BASIC:/size|/size]]3 (which evaluates to 16000) can't be replaced by 2^4<span style="font-size: 75%">E</span>3, since the latter is interpreted as 2^(4000).<br />
<br />
= Optimization =<br />
<br />
The * sign has the same truth value as the [[TI-BASIC:And|And]] operator because they both return zero if one or more of the numbers is zero (based on Boolean logic). Consequently, you sometimes see people implicitly multiplying expressions together in [[TI-BASIC:If|conditionals]] and [[TI-BASIC:While|loops]], instead of joining them together with and. Unfortunately, this is not only usually larger in size, but often times slower.<br />
<br />
<br />
:If (A=2)(B=7<br />
should be<br />
:If A=2 and B=7<br />
<br />
<br />
It does save some space when you can avoid using parentheses:<br />
<br />
:If A and B<br />
could be<br />
:If AB<br />
<br />
<br />
= Timing =<br />
<br />
The amount of time taken to multiply two real floating-point numbers varies with the sum of the digits (including in the fractional part) of the right argument. On a 15 MHz calculator, a single multiplication in the worst case (when the right argument is 99999999999999) takes 3.3 ms, the best case (when the right argument is 0) takes about 0.1 ms, and the average case (for fourteen-digit floating point numbers) takes about 1.7 ms.<br />
<br />
These timings do not include parser overhead or variable recall time, which are often significant in overall program speed.<br />
<br />
= Related Commands =<br />
<br />
* + ([[TI-BASIC:Add|Add]])<br />
* - ([[TI-BASIC:Subtract|Subtract]])<br />
* / ([[TI-BASIC:Divide|Divide]])[[Category:TI-BASIC]]<br />
[[Category:TIBD]]</div>Maintenance script