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

Sources/ucode/tests/custom/03_stdlib/08_int

  1 The `int()` function converts the given value into a signed integer
  2 value and returns the resulting number. In case the value is of type
  3 string, a second optional base argument may be specified which is
  4 passed to the underlying strtoll(3) implementation.
  5 
  6 Returns `NaN` if the given argument is not convertible into a number.
  7 Returns `NaN` if the conversion result is out of range.
  8 
  9 -- Testcase --
 10 {%
 11         printf("%.J\n", [
 12                 int(),
 13                 int(false),
 14                 int(123),
 15                 int(456.789),
 16                 int(""),
 17                 int("invalid"),
 18                 int("deaf"),
 19                 int("0x1000"),
 20                 int("0xffffffffffffffff"),
 21                 int("0177"),
 22                 int("+145"),
 23                 int("-96"),
 24                 int("0177", 8),
 25                 int("0x1000", 16),
 26                 int("1111", 2),
 27                 int("0xffffffffffffffff", 16)
 28         ]);
 29 %}
 30 -- End --
 31 
 32 -- Expect stdout --
 33 [
 34         0,
 35         0,
 36         123,
 37         456,
 38         "NaN",
 39         "NaN",
 40         "NaN",
 41         0,
 42         0,
 43         177,
 44         145,
 45         -96,
 46         127,
 47         4096,
 48         15,
 49         "NaN"
 50 ]
 51 -- End --

This page was automatically generated by LXR 0.3.1.  •  OpenWrt