diff --git a/wrapdc.sh b/wrapdc.sh index 3b5866d..19bbb80 100755 --- a/wrapdc.sh +++ b/wrapdc.sh @@ -17,23 +17,23 @@ fi # macros defined as sed patterns # (kill all '!' not part of comparison commands, and also comments) mcrs=' -s,%t,SAdLA100*SASBLALB/,g;# percent part: X:=100*X/Y, Y kept -s,%d,SAddLA-_100*SASBLALB/,g;# percent delta: X:=100*(X-Y)/Y, Y kept -s,%f,SAdlA*100LA-/,g;# percent future: X:=Y*X/(100-X), Y kept -s,%,SAdLA*100/,g;# percentage: X:=X*Y/100, Y kept +s,%t,S.dL.100*S.S:L.L:/,g;# percent part: X:=100*X/Y, Y kept +s,%d,S.ddL.-_100*S.S:L.L:/,g;# percent delta: X:=100*(X-Y)/Y, Y kept +s,%f,S.dl.*100L.-/,g;# percent future: X:=Y*X/(100-X), Y kept +s,%,S.dL.*100/,g;# percentage: X:=X*Y/100, Y kept s,hm,r60*+,g;# hoursminutes: X:=X+Y*60 s,rem,\%,g;# remainder: X:=Y%X (instead of normal '%' command) s,sto\(.\),s\1l\1,g;# sto.: store with copying (i.e keep value on stack) -s,fact,[SAlA*LA1-d0].*,, s,#.*,, ' @@ -97,16 +97,16 @@ l0n[s0 ]nl8n[s8 ]nl9n[s9 ]n -# clear stack, store 0 in reg.Z and macro in reg.Y, which compares stack +# clear stack, store 0 in reg.'.' and macro in reg.':', which compares stack # depth with 1 (in case of empty stack generated by this '1') and if equal, -# prints 0 (from reg.Z), else former top of stack, and clears stack -c 0sZ [1z=Znc]sY -# apply macro in reg.Y to all saved stack values, and separate with NL -LElYx[ -]nLDlYx[ -]nLClYx[ -]nLBlYx[ -]nlAlYx[ # ]n +# prints 0 (from reg.'.'), else former top of stack, and clears stack +c 0s. [1z=.nc]s: +# apply macro in reg.':' to all saved stack values, and separate with NL +LEl:x[ +]nLDl:x[ +]nLCl:x[ +]nLBl:x[ +]nlAl:x[ # ]n # print exponentialized version of stack top as comment: # A=(number of digits - number of fraction digits - 1) of stack top, # divide stack top by 10^A and print, print A