HP Forums
Ratio calculation command - 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: Ratio calculation command (/thread-7089.html)



Ratio calculation command - simone_71 - 10-23-2016 01:38 AM

Very often for work, but mostly because I'm used to always do so, I use the ratio calculation. I wrote a simple program that solves ratio calculation (a : b = c : d), and I want to share it with you here. The program automatically solve the equation for the term equal to zero.

Code:

//Ratio Function By Simone Selleri.
//Version 1.0 - October 2016
//This function solve a ratio equation (a:b=c:d)
//for the value equal to 0.
//
//SYNTAX:    ratio(a,b,c,d)
//Examples:    ratio(10,20,30,0) gives 60
//            ratio(10,20,0,60) gives 30
//            ratio(10,0,30,60) gives 20
//            ratio(0,20,30,60) gives 10
//any question mail to: simone.selleri@gmail.com
//
EXPORT ratio(a,b,c,d)
BEGIN
  a▶A;b▶B;c▶C;d▶D;
  "A/B=C/D"▶E2;
    CASE
      IF A==0 THEN SOLVE(E2,A);END;
      IF B==0 THEN SOLVE(E2,B);END;
      IF C==0 THEN SOLVE(E2,C);END;
      IF D==0 THEN SOLVE(E2,D);END;
    END;
END;

I hope will be useful!!!