What is the use of underline in numerical literals?

Asked

Viewed 181 times

10

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;

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 that:

private long milisegundosNoDia = 86400000;
  • 4

    Who Feature legal, all language should have this :)

  • 3

    @Renan right? I was frustrated when I discovered that there was no C

  • @Carlosheuberger Any Feature in the language can be abused or used incorrectly to make it more difficult, this here is no exception.

  • @Carlosheuberger

Browser other questions tagged

You are not signed in. Login or sign up in order to post.