-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from tsingbx/integers
add doc for integers
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,33 @@ | ||
// int type represents a whole number, which can be positive or negative. The | ||
// int type size is platform-dependent and will be either 32 or 64 bits. There are | ||
// also integer types that have a specific size, such as int8, int16, int32, int64, and | ||
// int128, but the int type should be used unless you need a specific size. | ||
// | ||
// uint type represents a positive whole number. The uint type size is platformdependent and will be either 32 or 64 bits. There are also unsigned integer | ||
// types that have a specific size, such as uint8, uint16, uint32, uint64 and uint128, but | ||
// the uint type should be used unless you need a specific size. | ||
// | ||
// For int 20 values can also be expressed in hex (0x14), octal (0o24), and binary notation (0b0010100). | ||
// uint, there are no uint literals. All literal whole numbers are treated as int values. | ||
// | ||
// Go+ also supports writing numbers with _ as separator and also support cast bool to number types. | ||
// As example shows | ||
|
||
num := 1_000_000 //Go+ support, same as 1000000 | ||
println num | ||
|
||
println int(true) //Go+ support cast bool to int | ||
println float64(true) //and to float64 | ||
println complex64(true) //and to complex64, and so on. | ||
|
||
println 20+20 | ||
println 20+30 | ||
println 0x14 //in hex | ||
println 0o24 //in octal | ||
println 0b0010100 // binary | ||
|
||
c := int128(12345) // If you want a different type of integer, you can use casting. | ||
println c | ||
|
||
u128 := uint128(12345) | ||
println(u128) |