HP Forums

Full Version: Program for converting degrees to radians and vise versa (HP Prime)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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).
(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;
Thank you so much! To start this would I go to the program tab?
(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.
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.
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
(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.
(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
Python math library has radians() & degrees() functions. Remember beforehand do
Code:
from math import *
Reference URL's