Literals/Integer: Difference between revisions
m
→{{header|Kotlin}}
(→{{header|Kotlin}}: Updated the Kotlin example to include unsigned types) |
|||
Line 1,194:
=={{header|Kotlin}}==
Kotlin supports 3 types of integer literal: decimal, hexadecimal and binary. Hexadecimal literals are prefixed with <code>0x</code> or <code>0X</code>, and binary literals with <code>0b</code> or <code>0B</code>. Hexadecimal digits can be uppercase or lowercase, or a combination of the two.
A signed integer literal can be assigned to a variable of any signed integer type. If no type is specified, Int (4 bytes) is assumed. If the value cannot fit into an Int, Long (8 bytes) is assumed.
An unsigned integer literal is made by appending
Signed and unsigned integer literals can be forced to be interpreted as Long or ULong respectively by appending the suffix
<syntaxhighlight lang="kotlin">
|