Reputation:
I came across this line of code written in rust and do not understand what is happening here. Can anyone explain this line of code written in rust?
let decimal = 65.4321_f32;
What does _f32
do?
Thanks in advance :)
Upvotes: 2
Views: 668
Reputation: 42716
In rust you can specify numeric types but adding a trailing tag:
0usize
0i32
0u32
0f32
0f64
...
Also you have the possibility of adding _
as a visual separator in numbers, it doesn't affect the final value itself (1_2_3
would be 123
anyway):
10
100
1000
10_000
100_000
1_000_000
...
By mixing both of them you arrive at the final form used in your question where the _
is used to separate the type tag itself:
10_000.1001_f32
You can take a look at the literal expressions documentation
Upvotes: 6