HP Forums
Handy Subroutines - 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: Handy Subroutines (/thread-3431.html)



Handy Subroutines - DrD - 03-19-2015 02:00 PM

Over time many handy subroutines have evolved that are especially useful. Things like the recent discussion of TUpper, and its inverse TLower for ASCII case management, for example.

Would having an "Important Thread" item that could warehouse useful subroutines be of any merit?

I can offer this one, which is designed to rescale a data point value from an (old min to old max) range to a (new min to new max) range. I've found it very handy, and have used it in several different prime programs:
Code:

//  ============================================
//                                                                                                      =
//                                      Rescale                                                 =
//                                                                                                      =
//  Input:     Datapoint d in range (old min, old max)      =
// Returns:  Value in range (new min, new max)              =
//                                                                                                      =
//  ============================================
rescale(omn,omx,nmn,nmx,d) 
BEGIN
   RETURN (((d-omn)*(nmx-nmn))/(omx-omn))+nmn; 
END;



RE: Handy Subroutines - bobkrohn - 03-19-2015 03:37 PM

I agree


RE: Handy Subroutines - salvomic - 03-19-2015 04:05 PM

thank you!