Post Reply 
Handy Subroutines
03-19-2015, 02:00 PM (This post was last modified: 03-19-2015 02:02 PM by DrD.)
Post: #1
Handy Subroutines
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;
Find all posts by this user
Quote this message in a reply
03-19-2015, 03:37 PM
Post: #2
RE: Handy Subroutines
I agree
Find all posts by this user
Quote this message in a reply
03-19-2015, 04:05 PM
Post: #3
RE: Handy Subroutines
thank you!

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)