Hello , I have 2 questions regarding
std::f64::consts::PI
Q1 : Is there a benefit (or motivation) behind specifying more than 14 digits below radix point for PI
?
According to the results I got from this experiment (in Rust Playground), specifying 14 digits (in base 10) below radix point in code seems "enough" when storing a PI
constant as f64
, since writing more digits doesn't affect the bit-level representation.
Meanwhile the definition of std::f64::consts::PI
specifies 35 digits below radix point in code.
// (from rust/library/core/src/num/f64.rs)
pub const PI: f64 = 3.14159265358979323846264338327950288_f64;
Q2 : Confusing comment shown in docs page of PI
Docs page for std::f64::consts::PI
displays the definition of PI
constant as below:
pub const PI: f64 = 3.14159265358979323846264338327950288f64; // 3.1415926535897931f64
What confuses me is the comment at the end of the line.
It specifies only 16 digits below radix point and the 16th digit ("1") differs from the 16th digit of the value stored to PI
in code ("0").
Rounding the PI
constant to the 16th digit doesn't result in the value specified in the comment.
When I looked at the source (by clicking the source
button in the docs page), I couldn't find such comment in the same file.
How is that comment generated? What information does it intend to give us?