HP Forums
Program for converting degrees to radians and vise versa (HP Prime) - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Program for converting degrees to radians and vise versa (HP Prime) (/thread-18216.html)



Program for converting degrees to radians and vise versa (HP Prime) - IsaiahG0701 - 04-03-2022 06:39 PM

I remember on the previous update I created a program that could convert degrees to radians and radians to degrees in maybe 1 or 2 keystrokes. Unfortunately, this program is no longer supported on my calculator. Rather than go through the units and do the tedious process of conversions. Is there a quicker and more effective method to do this. I remember the program being called D2R (Degrees to radians) and R2D (Radians to degrees).


RE: Program for converting degrees to radians and vise versa (HP Prime) - Tyann - 04-04-2022 05:33 AM

(04-03-2022 06:39 PM)IsaiahG0701 Wrote:  I remember on the previous update I created a program that could convert degrees to radians and radians to degrees in maybe 1 or 2 keystrokes. Unfortunately, this program is no longer supported on my calculator. Rather than go through the units and do the tedious process of conversions. Is there a quicker and more effective method to do this. I remember the program being called D2R (Degrees to radians) and R2D (Radians to degrees).

Bonjour
Voici ce que j'utilise, si ça peut vous aider.

Hello
Here's what I use, if it helps.

Code:

EXPORT D_R(d)
// Valeur en °
BEGIN
 UVAL(CONVERT(d*1_deg,0_rad));
END;
EXPORT R_D(r)
// Valeur en radians
BEGIN
 UVAL(CONVERT(r*1_rad,0_deg));
END;



RE: Program for converting degrees to radians and vise versa (HP Prime) - IsaiahG0701 - 04-04-2022 05:42 AM

Thank you so much! To start this would I go to the program tab?


RE: Program for converting degrees to radians and vise versa (HP Prime) - Tyann - 04-04-2022 10:53 AM

(04-04-2022 05:42 AM)IsaiahG0701 Wrote:  Thank you so much! To start this would I go to the program tab?

Oui vous allez dans l'onglet programme et vous créez un nouveau programme
puis vous entrez le code de ces 2 fonctions.

Yes you go to the program tab and create a new program
then you enter the code of these 2 functions.


RE: Program for converting degrees to radians and vise versa (HP Prime) - Didier Lachieze - 04-04-2022 12:15 PM

As these programs are single line programs you can also define user functions using the Shift Define key (to the right of the Units key):

[attachment=10500] [attachment=10501]

Just use upper case letters for the variables : D and R instead of d and r.


RE: Program for converting degrees to radians and vise versa (HP Prime) - IsaiahG0701 - 04-05-2022 04:42 PM

Thank you so much! With these programs would I be able to simplify a decimal number into radian form? Like if I were to do 7.5*(4pi/135) and get .698. Would I be able to have this simplified into 2pi/9


RE: Program for converting degrees to radians and vise versa (HP Prime) - roadrunner - 04-07-2022 12:36 PM

(04-05-2022 04:42 PM)IsaiahG0701 Wrote:  Would I be able to have this simplified into 2pi/9

Not with the programs above, but this:

Code:
EXPORT radexact(D)
BEGIN
 CAS(EVAL("exact("+(D/π)+")"))*CAS(π);
END;

program does do what you want.


RE: Program for converting degrees to radians and vise versa (HP Prime) - forexbob - 10-13-2022 10:15 PM

(04-07-2022 12:36 PM)roadrunner Wrote:  
(04-05-2022 04:42 PM)IsaiahG0701 Wrote:  Would I be able to have this simplified into 2pi/9

Not with the programs above, but this:

Code:
EXPORT radexact(D)
BEGIN
 CAS(EVAL("exact("+(D/π)+")"))*CAS(π);
END;

program does do what you want.

Hi,

I know this is late to the game... but I tried the above radexact program and it gives a strange result. I entered 45 degrees and it returned 38,646,433/2,698,030*pi when I would have expected pi/4. Is that an issue with Prime or the results that I can expect, which are not correct.

Thanks to anyone still "listening" to this thread.

Bob


RE: Program for converting degrees to radians and vise versa (HP Prime) - Ioncubekh - 10-23-2022 08:26 PM

Python math library has radians() & degrees() functions. Remember beforehand do
Code:
from math import *