{precision=>p} to reduce byte count

master
Mike Gerwitz 2021-01-27 16:52:31 -05:00
parent f14417f32a
commit 9dbda93b4f
2 changed files with 5 additions and 4 deletions

View File

@ -267,7 +267,7 @@
<text>var result=</text> <text>var result=</text>
<!-- if caller wants to yield a vector, don't cast --> <!-- if caller wants to yield a vector, don't cast -->
<sequence select="if ( not( $dim gt 0 ) ) then <sequence select="if ( not( $dim gt 0 ) ) then
concat( 'precision(', $precision, ', +(') concat( 'p(', $precision, ', +(')
else else
'('" /> '('" />
<choose> <choose>
@ -442,7 +442,7 @@
<text>Math.</text> <text>Math.</text>
<value-of select="local-name()" /> <value-of select="local-name()" />
<text>(precision(</text> <text>(p(</text>
<value-of select="$precision" /> <value-of select="$precision" />
<text>, +(</text> <text>, +(</text>
<apply-templates select="./c:*" mode="compile" /> <apply-templates select="./c:*" mode="compile" />

View File

@ -1402,7 +1402,7 @@
<!-- store the premium --> <!-- store the premium -->
<value-of select="$store" /> <value-of select="$store" />
<text>=precision(</text> <text>=p(</text>
<value-of select="$precision" /> <value-of select="$precision" />
<!-- return the result of the calculation for this rate block --> <!-- return the result of the calculation for this rate block -->
<text>,+(</text> <text>,+(</text>
@ -1654,7 +1654,8 @@
<template name="compiler:static"> <template name="compiler:static">
<text> <text>
<![CDATA[ <![CDATA[
function precision(p, x) // precision
function p(p, x)
{ {
if (x % 1 === 0) return x; if (x % 1 === 0) return x;
return Math.round(x * p) / p; return Math.round(x * p) / p;