How to resolve the algorithm Price fraction step by step in the Raven programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Price fraction step by step in the Raven programming language

Table of Contents

Problem Statement

A friend of mine runs a pharmacy.   He has a specialized function in his Dispensary application which receives a decimal value of currency and replaces it to a standard value.   This value is regulated by a government department.

Given a floating point value between   0.00   and   1.00,   rescale according to the following table:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Price fraction step by step in the Raven programming language

Source code in the raven programming language

define getScaleFactor use $v
   [ 0.1 0.18 0.26 0.32 0.38 0.44 0.50 0.54 0.58 0.62 0.66 0.70 0.74 0.78 0.82 0.86 0.90 0.94 0.98 1.0 ] as $vals
   $v 100 * 1 - 5 /    20 min  0 max  1 prefer dup $v "val: %g  indx: %d\n" print   $vals swap get

0 100 9 range each
    100.0 / dup getScaleFactor swap "%.2g -> %.2g\n" print

  

You may also check:How to resolve the algorithm Top rank per group step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Substring step by step in the Logo programming language
You may also check:How to resolve the algorithm Pernicious numbers step by step in the C programming language
You may also check:How to resolve the algorithm Matrix-exponentiation operator step by step in the ERRE programming language
You may also check:How to resolve the algorithm Convert decimal number to rational step by step in the Delphi programming language