What is the underline for numeric literals?

8

What is the use of underline (_) in the situations below:

float pi =  3.14159_26535_89793_23846;
long bytes = 00101001_00100110_01100001;
int n = 1____________________1;
    
asked by anonymous 05.10.2017 / 22:22

1 answer

11

It only serves to make reading easier. The compiler ignores them. For example, this:

private long milisegundosNoDia = 86_400_000;

It's easier to read (by a human) than this:

private long milisegundosNoDia = 86400000;
    
05.10.2017 / 22:25