Here are some helpful ideas for subroutines that deal with angle measures:
1. Detecting whether a calculator is in radian or degree mode. This is useful for programs that should input the answer in the angle measure unit that the calculator is currently in.
:If int(sin(90
This will run the line of code after it only if the calculator is in degree mode. Since the sine of 90 (degrees) is 1, it will run the next line of code if it interprets 90 as 90 degrees, which it would only do if the calculator is in degree mode. If the calculator is in radian mode, you get a messy decimal less than one, so the integer part will be 0 and the line will not run.
Here is an optimization of the code:
:If int(1°
This functions the exact same way, but it saves time and takes up less memory. If the calculator is in degree mode, it will interpret one degree as one, and take the integer part of this, which is also one. If the calculator is in radian mode, it will convert 1 degree to radians, which is a messy decimal smaller than 1. Therefore, it’s integer part is 0, and it will not run the next line of code.
Here is a line of code that will run only if the calculator is in radian mode. I would suggest using the ones above in all cases where the optimization would be better, but sometimes this may be useful:
:If not(int(1°
This incorporates a not because it is quicker and smaller than the ≠ operator, and it can also retain its Boolean nature, which speeds up calculation time much faster.
2. Expressing radian units in π/x form. This also sticks the radian symbol at the end. It shouldn’t be that hard to remove if you don’t want it there. If the angle measure in radians can not be expressed with π, it will round the number to 2 decimal places. This may not be fully optimized, but then again it might be. No matter how hard I look at a bit of code, I always assume that there is a possibility that someone might know better about how to simplify it. Please comment if you find a way. It shouldn’t matter all that much, but I would be really interested to see. I used the finance variable ”ℕ” for the number in my real program, as it is the fastest variable on the TI84+CE calc, but I didn’t want to get anybody confused so I will just use an “A” as the variable here for the radian measure. Also, please note that the tiny letter r at the end means to input the radian symbol here, NOT a real letter r. Also, the program may not correctly identify the measures which are divisors of π if the number has a decimal expansion smaller than 10 digits, because the calculator has a π built in that is accurate, and fPart can identify any fractional part up to 10 digits. This shouldn’t be a problem, but if it is undesired you can easily replace the first π in the code with a value of pi equivalent to the amount of decimal places you would like. My code only rounds if it has already been detected to not be a divisor of π. Feel free to also change the Disp part to anything you like. The actual calculations are complete after the answer has been stored to Str1, so do anything you like with Str1 after that point.
:If not(fPart(A/π
:Then
:”π/“+toString(A/π→Str1
:Else
:toString(round(A,2→Str1
:Disp Str1+”r”
:End
I hope you enjoyed! Please inform me of any possible optimizations or simpler subroutines, as I personally like to keep my programs as optimized as possible.