diff --git a/107-Integers/integers.gop b/107-Integers/integers.gop index 8b13789..20a559e 100644 --- a/107-Integers/integers.gop +++ b/107-Integers/integers.gop @@ -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)