HP Forums

Full Version: Gradian toolbox
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi to everybody!
I created a small program that provides conversion from radians or degrees to gradian and viceversa. There are also the three basic trigonometric functions and their inverse functions that work directly in gradians.
I hope it is useful to someone. If there are errors and bugs report it!

Code:

// Gradian Toolbox
// January 2016
// HAngle = 1 -> degrees mode
// HAngle = 0 -> radian mode
// Exact function removes approximation error
// Approx function convert decimal value to fraction whenever possible

// Converting to grads
EXPORT TO_GRAD(n)
BEGIN
IF HAngle == 1 THEN 
RETURN 10*n/9;
ELSE 
RETURN 200*n/π;
END;
END;

// Convert from grads
EXPORT FROM_GRAD(n)
BEGIN
IF HAngle == 1 THEN 
RETURN 9*n/10; 
ELSE 
RETURN n*π/200;
END;
END;

// Grads cosine
EXPORT COS_G(n)
BEGIN
RETURN COS(FROM_GRAD(n));
END;

// Grads sine
EXPORT SIN_G(n)
BEGIN
RETURN SIN(FROM_GRAD(n));
END;

// Grads tangent
EXPORT TAN_G(n)
BEGIN
RETURN TAN(FROM_GRAD(n));
END;

// Grads arccosine
EXPORT ACOS_G(n)
BEGIN
IF HAngle == 1 THEN 
RETURN approx(exact(10*ACOS(n)/9));
ELSE 
RETURN approx(exact(200*ACOS(n)/π));
END;
END;

// Grads arcsine
EXPORT ASIN_G(n)
BEGIN
IF HAngle == 1 THEN 
RETURN approx(exact(10*ASIN(n)/9));
ELSE 
RETURN approx(exact(200*ASIN(n)/π));
END;
END;

// Grads arctangent
EXPORT ATAN_G(n)
BEGIN
IF HAngle == 1 THEN 
RETURN approx(exact(10*ATAN(n)/9));
ELSE 
RETURN approx(exact(200*ATAN(n)/π));
END;
END;
thank you! very useful. Gradian should be an option in the Prime, like degree and radiants!

Salvo
(01-08-2016 06:41 PM)salvomic Wrote: [ -> ]thank you! very useful.

Useful for what? I am not questioning you, I just have no idea who still uses GRADS and for what purpose? I believe Surveying used them, but I've heard that has not been true for many years.
(01-09-2016 09:52 PM)rprosperi Wrote: [ -> ]Useful for what? I am not questioning you, I just have no idea who still uses GRADS and for what purpose? I believe Surveying used them, but I've heard that has not been true for many years.

military people use (used?) gradian in their operations...
I can still see gradian examples in old Italian Mathematics's books.
Sure you have already seen here: https://en.wikipedia.org/wiki/Gradian for some ideas.
However I mean: it's useful to have in the Prime also Gradian (not only Degree and Radians): better many than few Smile

Salvo
Thanks a Lot Big Grin !!! IT IS VERY USEFUL Big Grin !!!
Just downloaded it - thank you.
Reference URL's