Price fraction: Difference between revisions

m (syntax highlighting fixup automation)
Line 4,077:
</syntaxhighlight>
 
=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.7}}
{| class="wikitable"
! RPL code
! Comment
|-
|
≪ → input
≪ { 0.10 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.06 0.11 0.16 0.21 0.26 0.31 0.36
0.41 0.46 0.51 0.56 0.61 0.66 0.71
0.76 0.81 0.86 0.91 0.96 1.01 }
1 WHILE GETI input < REPEAT END
IF DUP 1 == THEN DROP DUP SIZE ELSE 1 - END
SWAP DROP GET 2 FIX
≫ ≫ 'PRICE' STO
|
'''PRICEq''' ''( gross -- net ) ''
list of net values
.
.
list of thresholds
.
.
scan thresholds until passed
1 step down
forget thresholds and get net value with 2 decimals
.
|}
 
{{in}}
<pre>
0 PRICE
0.25 PRICE
0.5 PRICE
0.75 PRICE
1 PRICE
</pre>
 
{{out}}
<pre>
5: 0.10
4: 0.38
3: 0.62
2: 0.82
1: 1.00
</pre>
 
=={{header|Ruby}}==
1,150

edits