Zero to the zero power: Difference between revisions
Content added Content deleted
(Fix Wikipedia links: Zero to the Power of Zero has a dedicated page now.) |
(→{{header|jq}}: jq, gojq, fq) |
||
Line 724: | Line 724: | ||
=={{header|jq}}== |
=={{header|jq}}== |
||
{{works with|jq|1.5}} |
|||
jq version 1.4 does not have a builtin "power" function. If it were to be defined |
|||
'''Also works with gojq and fq''' |
|||
using the exp and log builtins as 'log * y | exp', then 0 | power(0) would yield null, and therefore |
|||
<pre> |
|||
a definition that makes a special case of 0^0 should be considered, e.g. |
|||
$ jq -n 'pow(0;0)' |
|||
along the following lines: |
|||
1 |
|||
<syntaxhighlight lang="jq">def power(y): y as $y | if $y == 0 then 1 elif . == 0 then 0 else log * $y | exp end;</syntaxhighlight> |
|||
</pre> |
|||
It is also worth noting that in jq, gojq, and fq, `pow(0; infinite)` yields 0. |
|||
This definition will however be unsatisfactory for many purposes |
|||
because it does not maintain precision for integer values of the input (.) and y. |
|||
=={{header|Jsish}}== |
=={{header|Jsish}}== |