Difference between revisions of "TI-BASIC:Number Concatenation"
From Learn @ Cemetech
Jump to navigationJump to search (Initial automated import) |
(Automated superscript correction) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Template:TI-BASIC:Routine | {{Template:TI-BASIC:Routine | ||
− | |picture= | + | |picture= |
|summary=Concatenates two whole numbers together. | |summary=Concatenates two whole numbers together. | ||
|input=''M'' - the first number | |input=''M'' - the first number | ||
Line 8: | Line 8: | ||
|compatibility=TI-83/84/+/SE | |compatibility=TI-83/84/+/SE | ||
|author=DarkerLine | |author=DarkerLine | ||
− | |authors= | + | |authors= |
|url=http://www.unitedti.org/index.php?showtopic=2664&view=findpost&p=46595 United TI | |url=http://www.unitedti.org/index.php?showtopic=2664&view=findpost&p=46595 United TI | ||
|download=[file numberconcatenation.zip] | |download=[file numberconcatenation.zip] | ||
Line 15: | Line 15: | ||
:N+M10^(1+int(log(N→O | :N+M10^(1+int(log(N→O | ||
− | With our two numbers stored in M and N respectively, we add the first number to the second number by raising it to the 10 | + | With our two numbers stored in M and N respectively, we add the first number to the second number by raising it to the 10<sup>th</sup> power, with the exponent being how many digits are in the number. We then store this result to a new variable for later use. |
We can figure out how many digits are in a number by using the 1+int(log( trick. This trick works with any positive whole numbers, and if you add [[TI-BASIC:Abs|Abs(]] after [[TI-BASIC:Log|Log(]], it will also work with negative numbers. Unfortunately, it does not work with decimals.[[Category:TI-BASIC]] | We can figure out how many digits are in a number by using the 1+int(log( trick. This trick works with any positive whole numbers, and if you add [[TI-BASIC:Abs|Abs(]] after [[TI-BASIC:Log|Log(]], it will also work with negative numbers. Unfortunately, it does not work with decimals.[[Category:TI-BASIC]] | ||
[[Category:TIBD]] | [[Category:TIBD]] |
Latest revision as of 22:25, 24 February 2016
Routine Summary
Concatenates two whole numbers together.
Inputs
M - the first number N - the second number
Outputs
O - the concatenated number
Variables Used
M, N, O
Calculator Compatibility
TI-83/84/+/SE Author
DarkerLineURL: United TI Download
:N+M10^(1+int(log(N→O
With our two numbers stored in M and N respectively, we add the first number to the second number by raising it to the 10th power, with the exponent being how many digits are in the number. We then store this result to a new variable for later use.
We can figure out how many digits are in a number by using the 1+int(log( trick. This trick works with any positive whole numbers, and if you add Abs( after Log(, it will also work with negative numbers. Unfortunately, it does not work with decimals.