Showing posts with label Banker's Rounding. Show all posts
Showing posts with label Banker's Rounding. Show all posts

Saturday, June 24, 2023

Casio fx-3650P Program Bank

Casio fx-3650P Program Bank



Economic Order Quantity


The program calculates three business parameters:


*  EOQ:  Economic Order Quantity: this is the optimum number of units to order in a single of order of items to be sold.  Each single inventory item has its on economic order quantity.   The calculation assumes every order will be available when needed.  This number of units is theoretical.  The calculation takes the estimated annual sales of units into account.  


*  The estimated amount of orders needed in a year.


*  The estimated annual cost of inventory.


Note that no amounts are rounded in this algorithm, all results are based on the theoretical values.


Formulas:


EOQ = √(2 × A × B ÷ (C% × D))


where:

A = cost to  place an order

B = annual sales of units

C = holding costs percentage 

D = cost per unit

EOQ is stored in X.


Orders per Year = B ÷ EOQ

The result is stored in Y. 


Estimated Annual Cost = A × amount of orders per year

Estimated annual cost is stored in M.



Program Code:  (47 steps)

(spaces are included for clarity)


Fix 2 : ? → A : ? → B : ? → C : ? → D : 

√ ( 2 A B ÷ 100(^-1) C × D → X ◢

B ÷ X → Y ◢

A Y → M ◢

Norm 1



Example:


Inputs:

A = cost to  place an order = $ 79.36

B = annual sales of units = 100,000

C = holding costs percentage = 24%

D = cost per unit = $ 1.20


Outputs:

X = EOQ ≈ 7,423.69

Y = Orders per Year ≈ 13.47

M = Estimated annual cost ≈ $1,069.01


Source:


Hewlett Packard.   Step-by-Step Solutions For Your HP Calculator: Marketing and Sales:  HP-17B, HP-19B, HP-27S.   Hewlett Packard.  Edition 1.  January 1988. 



Banker's Rounding


We will focus on rounding positive numbers to integers.   


Banker's rounding is similar to regular rounding except, when the number has a fraction part of 0.5, the number is rounded to the nearest even integer.


For example:  both 17.5 and 18.5 would be rounded to 18.  


We can accomplish Banker's rounding by these algorithms, assuming x is a positive number (x>0):


If abs(frac(x)) = 0.5 

Then round(x ÷ 2, 0) × 2

Else round(x, 0) 

IfEnd


If mod(x,1) = 0.5

Then round(x ÷ 2, 0) × 2

Else round(x, 0) 

IfEnd


The fx-3650P does not have a modulus or absolute value function.   We can accomplish absolute value by using √(x^2).


Program Code:  (46 steps)

(spaces are included for clarity)


? → A : Fix 0 : Rnd : Ans → B :

√ ( ( A - B ) ² ) ≠ 0.5 ⇒ Goto 1 :

A ÷ 2 : Rnd : 2 Ans → B :

Lbl 1 : Norm 1: B


Examples:


A = 36.3,  result = 36

A = 36.5,  result = 36

A = 37.5,  result = 38

A = 40.5,  result = 40

A = 41.2,  result = 41



Birthday Probably Function


What are odds that A people/objects do not a share a characteristic in C categories?   


Famously stated:  what are odds that N people do not share a birthday in a 365-day year?  


The probability is calculated as:


p = Π(1 - m ÷ C, m = 1, N - 1) = nPr(C, N) ÷ C^N



Program Code:  (19 steps)

(spaces are included for clarity)


? → A : ? → C :

C [nPr] A ÷ ( C ^ A ) → B


nPr appears as a bold P.


Example:


Probability that 24 people do not share a birthday:

A = 24, C = 365,  result = 0.461655742


Probability that 40 students who do not share a college class, if the college offers 300 classes:

A = 40, C = 300, result = 0.065725193



Voltage Drop of a Copper Wire


The program calculates the voltage drop of a copper wire (conductivity of 12.9).  The wire is assumed to be insulated at 75°C. 


Formula:


1 Phase: (domestic and office appliances)

VD = 2 × 12.9 × B × D ÷ C


3 Phase: (large electronic equipment)

VD = √3 × 12.9 × B × D ÷ C = 1-Phase-VD × √3 ÷ 2


B = current (amps)

C = circular mils* (see below)

D = length of the wire (feet)


C:  

Enter the wire cross area in circular mils.  However, the code allows for three common wire types:


C = 10  (AWG 10):  10,380

C = 12  (AWG 12):  6,530

C = 14  (AWG 14):  4,110


The voltage drop for both 1 phase (stored in X), followed by 3 phase circuits (stored in Y) are displayed.  


Program Code:  (72 steps)

(spaces are included for clarity)


? → B :

? → C :

C = 10 ⇒ 10380 → C :

C = 12 ⇒ 6530 → C :

C = 14 ⇒ 4110 → C :

? → D :

2 × 12.9 × B × D ÷ C → X ◢

X × √3 ÷ 2 → Y


Examples:


Input:

B = Current = 300 A

C = 10  for a #10 AWG wire

D = Length = 24 ft


1 phase voltage drop:  17.89595376

3 phase voltage drop:  15.49835058



Input:

B = Current = 320 A

C = 14  for a #14 AWG wire

D = Length = 30 ft


1 phase voltage drop:  60.26277372

3 phase voltage drop:  52.18909295



Eddie


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Monday, November 26, 2018

TI-84 Plus and HP 12C Platinum: Banker's Rounding Method

TI-84 Plus and HP 12C Platinum:  Banker's Rounding Method

Introduction 

The banker's  rounding method involves rounding numeric amounts to the nearest integer.  When the number ends in 0.5  (1.5, 3.5, 8.5, etc), special rules apply:

The decimal gets rounded to the nearest even integer.  For example:  0.5,  2.5, and 4.5 round down to 0, 2, and 4 respectively.  However, 1.5, 3.5, and 5.5 are rounded up to 2, 4, and 6 respectively.

TI-84 Plus Program:  BANKRND

"2018-11-22 EWS"
Disp "BANKER'S ROUNDING"
Prompt X
iPart(X) → I
fPart(X) → F

If F=0.5
Then

If fPart(I/2)=0
Then
I → N
Else
I+1 → N
End

Else
round(X,0) → N
End
Disp N

HP 12C Platinum Program: Banker's Rounding

Note: Use two-digit addresses for the regular HP 12C.

Memory addresses needed: registers 0 through 4.  

Step  Key

001  STO 0
002  INTG
003  STO 1
004  LSTx  
005  FRAC
006  STO 2
007   .
008  5
009   -
010   x=0
011   GTO 018
012   RCL 0
013   FIX 0
014   RND
015   STO 4
016   FIX 2
017   GTO 000
018   RCL 1 
019   2
020   ÷
021   FRAC
022   x=0
023   GTO 029
024   RCL 1
025   1
026   +
027   STO 4
028   GTO 000
029   RCL 1
030   STO 4
031   GTO 000

Source:

"Bankers Rounding"  http://wiki.c2.com/?BankersRounding  Retrieved November 22, 2018


Eddie

All original content copyright, © 2011-2018.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions.

Retro Review: HP 65

Retro Review: HP 65 Quick Facts Company: Hewlett Packard Years: 1974 - 1977 Type: Scientific, RPN (Reverse Polish Notation) Mem...