Skip to content

Commit 187b5f6

Browse files
committed
modify doc for integers
1 parent 529dc61 commit 187b5f6

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

107-Integers/integers.gop

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@
77
// types that have a specific size, such as uint8, uint16, uint32, and uint64, but
88
// the uint type should be used unless you need a specific size.
99
//
10-
// int Literal Values
11-
// Gop values can be expressed literally, where the value is defined directly in the source code file. Common
12-
// uses for literal values include operands in expressions and arguments to functions, as shown following:
10+
// For int 20 values can also be expressed in hex (0x14), octal (0o24), and binary notation (0b0010100).
11+
// uint, there are no uint literals. All literal whole numbers are treated as int values.
12+
//
13+
// Go+ also supports writing numbers with _ as separator:
14+
15+
num := 1_000_000 //Go+ support, same as 1000000
16+
println num
1317

1418
println 20+20
1519
println 20+30
20+
println 0x14 //in hex
21+
println 0o24 //in octal
22+
println 0b0010100 // binary
1623

17-
// int 20, Values can also be expressed in hex (0x14), octal (0o24), and binary notation (0b0010100).
18-
// unit There are no uint literals. All literal whole numbers are treated as int values.
24+
c := int128(12345) // If you want a different type of integer, you can use casting.
25+
println c

0 commit comments

Comments
 (0)