Integer (int)
All integer numbers. See Numbers for more information.
Returned by
Integer objects are returned by the following functions and methods:
get_option()array.length()bool.to_int()cfg_data.get()cfg_data.get_unquoted()compiler.alignment()compiler.compute_int()compiler.sizeof()runresult.returncode()str.to_int()
Integer methods
int.is_even()
Returns true if the number is even.
Signature
bool is_even()
int.is_odd()
Returns true if the number is odd
Signature
bool is_odd()
int.to_string()
Returns the value of the number as a string.
Signature
# Returns the value of the number as a string
str to_string(
int [fill], # Left fill the string with zeros until it reaches the length
# Keyword arguments:
format : str # How to format the number; can be one of 'dec' (decimal), 'hex'
)
Example
assert(255.to_string(format: 'dec') == '255')
assert(255.to_string(format: 'hex') == '0xff')
assert(255.to_string(format: 'oct') == '0o377')
assert(255.to_string(format: 'bin') == '0b11111111')
Arguments
The method int.to_string() accepts the following positional arguments:
| Name | Type | Description | Tags |
|---|---|---|---|
fill |
int |
Left fill the string with zeros until it reaches the length
specified by this argument. A leading negative sign counts towards
the length, and is handled by inserting the padding after the |
[optional] |
Finally, int.to_string()
accepts the following keyword arguments:
| Name | Type | Description | Tags |
|---|---|---|---|
format |
str |
How to format the number; can be one of 'dec' (decimal), 'hex' (hexadecimal), 'oct' (octal), or 'bin' (binary). For formats other than 'dec', the string will be appropriately prefixed (e.g., for 'hex', the string will begin with '0x', etc.) |
(since 1.12.0)
|
The results of the search are