(11C) Margin and Markup conversion
02-03-2018, 10:45 AM
Post: #1
 Gamo Member Posts: 245 Joined: Dec 2016
(11C) Margin and Markup conversion
This program make conversion between gross margin and markup (Gross Profit)

https://en.wikipedia.org/wiki/Gross_margin

Example:
LBL A ( Known Margin) convert to Markup
LBL B (Known Markup) convert to Margin

Margin 44.44% > 44.44 A result 80%
Markup 75% > 75 B result 42.85%

Program:

Code:
 LBL A (Known Margin) CF 0 GTO 1 LBL B (Known Markup) SF 0 LBL 1 1/x EEX CHS 2 F0 GTO 2 - 1/x RTN LBL 2 + 1/x RTN

Gamo
02-03-2018, 12:06 PM (This post was last modified: 02-03-2018 05:18 PM by Dieter.)
Post: #2
 Dieter Senior Member Posts: 2,021 Joined: Dec 2013
RE: (11C) Margin and Markup conversion
(02-03-2018 10:45 AM)Gamo Wrote:  This program make conversion between gross margin and markup (Gross Profit)

Hint: a – b = a + (–b)   ;-)

Code:
LBL A (Known Margin) SF 0 GTO 1 LBL B (Known Markup) CF 0 LBL 1 1/x , 0 1 F? 0 CHS + 1/x RTN

That's one of the basic RPN programming tricks:

F?0 CHS +  adds x if flag 0 is clear and subtracts x if flag 0 is set.
F?0 1/X  ×  multiplies by x if flag 0 is clear and divides by x if flag 0 is set.

But the used formula does not allow a zero margin or markup. That's why I'd suggest you better do it by calculating 100·x / (100±x) :

Code:
LBL A (Known Margin) SF 0 GTO 1 LBL B (Known Markup) CF 0 LBL 1 EEX 2 x<>y x EEX 2 LastX F? 0 CHS + / RTN

Edit: Here is my favourite version.

Code:
LBL A   -margin <=> markup ENTER ENTER 1 x<>y % + / CHS RTN

Rule:
margin is negative
markup is positive

–44,44 [A] =>   80,00
75,00 [A] => –42,86

This one requires no flags or labels. So it even runs on a 12C, or probably on any RPN programmable HP.

Of course it works only for positive markups and margins, but I hope you do not have to deal with negative ones. ;-)

Dieter
 « Next Oldest | Next Newest »

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