• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/tests/custom/00_syntax/26_exponentiation

  1 The exponentiation and exponentiation assignment operands allow raising
  2 the base operand value to the given power.
  3 
  4 
  5 1. The `**` operator returns the result of raising the first operand to
  6 the power of the second operand.
  7 
  8 -- Expect stdout --
  9 [
 10         1,
 11         4,
 12         9223372036854775808,
 13         -9223372036854775808,
 14         -0.25,
 15         2.7556759606311
 16 ]
 17 -- End --
 18 
 19 -- Testcase --
 20 {%
 21         printf("%.J\n", [
 22                 2 ** 0,
 23                 2 ** 2,
 24                 2 ** 63,
 25                 -2 ** 63,
 26                 -2 ** -2,
 27                 1.5 ** 2.5
 28         ]);
 29 %}
 30 -- End --
 31 
 32 
 33 2. The `**=` operator raises the lhs variable or field value to the
 34 power value in the rhs expression.
 35 
 36 -- Expect stdout --
 37 [
 38         4,
 39         -0.25,
 40         2.7556759606311
 41 ]
 42 -- End --
 43 
 44 -- Testcase --
 45 {%
 46         x = 2;
 47         y = -2;
 48         z = 1.5;
 49 
 50         x **= 2;
 51         y **= -2;
 52         z **= 2.5;
 53 
 54         printf("%.J\n", [ x, y, z ]);
 55 %}
 56 -- End --

This page was automatically generated by LXR 0.3.1.  •  OpenWrt