Inflation Calculator (NSTK) (GBP)

Contributions to this software library are always welcome. Please ensure that you post program listings rather than .raw files. They give a reasonable idea of what your program does without having to load them into a DM42 and you can also include comments in your code. Check out the following link for a decoder/encoder: https://technical.swissmicros.com/decoders/dm42/

You can then copy/paste the listing and post it in "code" tags.
Post Reply
User avatar
dm319
Posts: 144
Joined: Thu Aug 03, 2017 12:21 pm
Location: Birmingham, UK

Inflation Calculator (NSTK) (GBP)

Post by dm319 »

This program is to solve the "how much would this cost now?" type questions.

It is very basic, there are 4 buttons:

YR1 : input the original year
$1 : input the original value
YR2 : input year you wish value to be found of (default 2024)
$2 : press to obtain value for YR2

There is no error checking, no extrapolation, no interpolation. The range of dates is from 1776 to 2024. The data is for GBP sterling, but you can use any data as long as it is supplied as a matrix where the first column is year, second column is relative value. The code requires every year to be represented.

There is a program to build the matrix, I copied the inflation data from here, opened it in Libreoffice Calc, and copy pasted the two columns I needed (without headers) into free/plus42 which creates the matrix into X. Selected PON to switch on printing. Using Werners PRMP program, I printed out the listing for generating the matrix. If you paste that into a protram, you can then get your data onto your DM42, name the matrix "INFL".

I can add data for other currencies if people want - if you can point me to the data that would be helpful.

Immediate thoughts for improvement:
  • Display alpha of year / YR2 with result
  • Probably should use program menu given only one button runs any code
  • Could adapt so it works for missing years by interpolation
  • Could do a reverse look-up to find the year it would be of a particular value
This is the code:

Code: Select all

00 { 152-Byte Prgm }
01▸LBL "INFLT"
02 MVAR "YR1"
03 MVAR "$1"
04 MVAR "YR2"
05 MVAR "$2"
06 XEQ 01
07▸LBL 02
08 CLA
09 VARMENU "INFLT"
10 STOP
11 ALENG
12 X=0?
13 GTO 06
14 DROP
15 ASTO "var"
16 XEQ IND "var"
17 GTO 02
18▸LBL 01
19 2024
20 STO "YR2"
21 DROP
22 RTN
23▸LBL 06
24 DROP
25 GTO 02
26 RTN
27▸LBL "$2"
28 INDEX "INFL"
29 1
30 1
31 STOIJ
32 DROPN 2
33 RCL "YR1"
34 [FIND]
35 GTO 03
36 RTN
37▸LBL 03
38 DROP
39 J+
40 RCLEL
41 1
42 1
43 STOIJ
44 DROPN 2
45 RCL "YR2"
46 [FIND]
47 XEQ 05
48 RTN
49▸LBL 05
50 J+
51 DROP
52 RCLEL
53 X<>Y
54 ÷
55 RCL "$1"
56 ×
57 RTN
58 END
Code is public domain.
Attachments
INMAT.raw
(3.96 KiB) Downloaded 11 times
INFL.raw
(155 Bytes) Downloaded 10 times
SN:09075
Post Reply