1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

doc: add info about _ separator in literals (#5823)

This commit is contained in:
Swastik Baranwal
2020-07-14 19:16:13 +05:30
committed by GitHub
parent c3ec5323f0
commit c3bdacbf04
2 changed files with 42 additions and 0 deletions

View File

@ -144,6 +144,33 @@ fn test_oct() {
assert x9 == 0
}
fn test_num_separator() {
// int
assert 100_000_0 == 1000000
assert -2_23_4_6 == -22346
assert 230_ == 230
// bin
assert 0b0_11 == 3
assert -0b0_100 == -4
assert 0b010_ == 2
// oct
assert 0o_173 == 123
assert -0o_175 == -125
assert -0o175_ == -125
// hex
assert 0x_FF == 255
assert 0xFF_ == 255
assert 0xF_F == 255
// f32 or f64
assert 312_2.55 == 3122.55
assert 312_2.55 == 3122.55
}
fn test_int_decl() {
x1 := 0
x2 := 1333