Difference between revisions of "TI-BASIC:Number Subset"
(Initial automated import) |
(Automated @@ correction) |
||
Line 1: | Line 1: | ||
{{Template:TI-BASIC:Routine | {{Template:TI-BASIC:Routine | ||
− | |picture= | + | |picture= |
|summary=Returns a subset of a number. | |summary=Returns a subset of a number. | ||
|input=''A'' - the number to get the subset from | |input=''A'' - the number to get the subset from | ||
Line 9: | Line 9: | ||
|compatibility=TI-83/84/+/SE | |compatibility=TI-83/84/+/SE | ||
|author=Weregoose | |author=Weregoose | ||
− | |authors= | + | |authors= |
|url=http://www.unitedti.org/index.php?showtopic=2664&hl= United TI | |url=http://www.unitedti.org/index.php?showtopic=2664&hl= United TI | ||
|download=[file numbersubset.zip] | |download=[file numbersubset.zip] |
Latest revision as of 22:11, 24 February 2016
Routine Summary
Returns a subset of a number.
Inputs
A - the number to get the subset from B - the starting position of the subset C - the length of the subset
Outputs
Ans - the subset of the number
Variables Used
A, B, C, Ans
Calculator Compatibility
TI-83/84/+/SE Author
WeregooseURL: United TI Download
:10^(2-B+int(log(A :int((A-int(A/Ans)Ans)/Ans10^(C
With our number stored in A, and the staring position and length of the subset stored in B and C respectively, we get the subset of the number by first subtracting the number divided by 10 to the power of 2-B+int(log(A (which is used to get how many digits are in the number), and then dividing that result by multiplying 10 to the power of 2-B+int(log(A and 10 to the power of C (which is the length of the subset).
A simple example should help you understand this routine. Say you input the number 123, with a starting position of 2 and a length of 2, it will return a result of 23. You can also use negative and decimal numbers with the routine, and it will still work correctly: a number of 13579.02468 with a starting position of 4 and length 4 will return 7902.
This routine is comparable to the Sub( command that works with Strings.